From fa42d37e2f0b93139ce960e5d8b837c56ce087d2 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Sat, 9 Mar 2024 19:49:11 +0100 Subject: [PATCH] chore: moved rowcol trait impl into proto --- src/lib.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 03b580a..0a8a202 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,12 +36,37 @@ pub mod files { pub mod buffer { tonic::include_proto!("buffer"); } + pub mod cursor { tonic::include_proto!("cursor"); + + impl From for (i32, i32) { + fn from(pos: RowCol) -> (i32, i32) { + (pos.row, pos.col) + } + } + + impl From<(i32, i32)> for RowCol { + fn from((row, col): (i32, i32)) -> Self { + RowCol { row, col } + } + } + + impl PartialOrd for RowCol { + fn partial_cmp(&self, other: &Self) -> Option { + match self.row.partial_cmp(&other.row) { + Some(core::cmp::Ordering::Equal) => {} + ord => return ord, + } + self.col.partial_cmp(&other.col) + } + } } + pub mod workspace { tonic::include_proto!("workspace"); } + pub mod auth { tonic::include_proto!("auth"); }