Skip to content

Commit

Permalink
impl try_from Range<usize> for textRange
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyJado committed Mar 25, 2023
1 parent e4d0f2b commit 480ae96
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/range.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
use std::{
convert::{TryFrom, TryInto},
num::TryFromIntError,
};

use cmp::Ordering;

use {
Expand Down Expand Up @@ -392,6 +397,14 @@ where
}
}

impl TryFrom<Range<usize>> for TextRange {
type Error = TryFromIntError;
#[inline]
fn try_from(r: Range<usize>) -> Result<Self, TryFromIntError> {
Ok(Self::new(r.start.try_into()?, r.end.try_into()?))
}
}

macro_rules! ops {
(impl $Op:ident for TextRange by fn $f:ident = $op:tt) => {
impl $Op<&TextSize> for TextRange {
Expand Down

0 comments on commit 480ae96

Please sign in to comment.