Skip to content

Commit

Permalink
impl From<Cursor> for CCursor {
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jan 23, 2024
1 parent 4b88798 commit a9c7768
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/epaint/src/text/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct CCursor {
}

impl CCursor {
#[inline]
pub fn new(index: usize) -> Self {
Self {
index,
Expand All @@ -25,9 +26,17 @@ impl CCursor {
}
}

impl From<Cursor> for CCursor {
#[inline]
fn from(c: Cursor) -> Self {
c.ccursor
}
}

/// Two `CCursor`s are considered equal if they refer to the same character boundary,
/// even if one prefers the start of the next row.
impl PartialEq for CCursor {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.index == other.index
}
Expand Down Expand Up @@ -106,6 +115,7 @@ pub struct PCursor {
/// Two `PCursor`s are considered equal if they refer to the same character boundary,
/// even if one prefers the start of the next row.
impl PartialEq for PCursor {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.paragraph == other.paragraph && self.offset == other.offset
}
Expand Down

0 comments on commit a9c7768

Please sign in to comment.