Fix docs
diff --git a/src/range.rs b/src/range.rs
index 3b946ab..fcf286d 100644
--- a/src/range.rs
+++ b/src/range.rs
@@ -98,8 +98,8 @@
/// let range = TextRange::up_to(point);
///
/// assert_eq!(range.len(), point);
- /// assert_eq!(range, TextRange::new(TextSize::zero(), point));
- /// assert_eq!(range, TextRange::at(TextSize::zero(), point));
+ /// assert_eq!(range, TextRange::new(0.into(), point));
+ /// assert_eq!(range, TextRange::at(0.into(), point));
/// ```
#[inline]
pub fn up_to(end: TextSize) -> TextRange {
@@ -254,7 +254,7 @@
/// ```rust
/// # use text_size::*;
/// assert_eq!(
- /// TextRange::empty(TextSize::zero()).cover_offset(20.into()),
+ /// TextRange::empty(0.into()).cover_offset(20.into()),
/// TextRange::new(0.into(), 20.into()),
/// )
/// ```
diff --git a/tests/constructors.rs b/tests/constructors.rs
index 9c9d080..9ff4e19 100644
--- a/tests/constructors.rs
+++ b/tests/constructors.rs
@@ -1,35 +1,24 @@
-use {
- std::{borrow::Cow, sync::Arc},
- text_size::*,
-};
+use text_size::TextSize;
#[derive(Copy, Clone)]
struct BadRope<'a>(&'a [&'a str]);
impl BadRope<'_> {
fn text_len(self) -> TextSize {
- self.0.iter().map(TextSize::of).sum()
+ self.0.iter().copied().map(TextSize::of).sum()
}
}
#[test]
fn main() {
- macro_rules! test {
- ($($expr:expr),+ $(,)?) => {
- $(let _ = TextSize::of($expr);)+
- };
- }
+ let x: char = 'c';
+ let _ = TextSize::of(x);
- test! {
- "",
- &"",
- 'a',
- &'a',
- &String::new(),
- &String::new().into_boxed_str(),
- &Arc::new(String::new()),
- &Cow::Borrowed(""),
- }
+ let x: &str = "hello";
+ let _ = TextSize::of(x);
+
+ let x: &String = &"hello".into();
+ let _ = TextSize::of(x);
let _ = BadRope(&[""]).text_len();
}
diff --git a/tests/main.rs b/tests/main.rs
index f8eb6d6..5e6b86d 100644
--- a/tests/main.rs
+++ b/tests/main.rs
@@ -26,7 +26,7 @@
assert_eq!(size(1).checked_add(size(1)), Some(size(2)));
assert_eq!(size(1).checked_sub(size(1)), Some(size(0)));
assert_eq!(size(1).checked_sub(size(2)), None);
- assert_eq!(TextSize::MAX.checked_add(size(1)), None);
+ assert_eq!(size(!0).checked_add(size(1)), None);
}
#[test]