We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e4d0f2b commit 480ae96Copy full SHA for 480ae96
src/range.rs
@@ -1,3 +1,8 @@
1
+use std::{
2
+ convert::{TryFrom, TryInto},
3
+ num::TryFromIntError,
4
+};
5
+
6
use cmp::Ordering;
7
8
use {
@@ -392,6 +397,14 @@ where
392
397
}
393
398
394
399
400
+impl TryFrom<Range<usize>> for TextRange {
401
+ type Error = TryFromIntError;
402
+ #[inline]
403
+ fn try_from(r: Range<usize>) -> Result<Self, TryFromIntError> {
404
+ Ok(Self::new(r.start.try_into()?, r.end.try_into()?))
405
+ }
406
+}
407
395
408
macro_rules! ops {
396
409
(impl $Op:ident for TextRange by fn $f:ident = $op:tt) => {
410
impl $Op<&TextSize> for TextRange {
0 commit comments