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 28d49f8Copy full SHA for 28d49f8
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,17 @@ 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
+ let start = r.start.try_into()?;
405
+ let end = r.end.try_into()?;
406
+ assert!(start <= end);
407
+ Ok(Self::new(start, end))
408
+ }
409
+}
410
395
411
macro_rules! ops {
396
412
(impl $Op:ident for TextRange by fn $f:ident = $op:tt) => {
413
impl $Op<&TextSize> for TextRange {
0 commit comments