Skip to content

Commit ccae768

Browse files
committed
Drop unused API
1 parent 24015a8 commit ccae768

File tree

3 files changed

+15
-59
lines changed

3 files changed

+15
-59
lines changed

src/range.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl TextRange {
8080
/// assert_eq!(range, TextRange::new(point, point));
8181
/// ```
8282
#[inline]
83-
pub const fn empty(offset: TextSize) -> TextRange {
83+
pub fn empty(offset: TextSize) -> TextRange {
8484
TextRange {
8585
start: offset,
8686
end: offset,
@@ -102,9 +102,11 @@ impl TextRange {
102102
/// assert_eq!(range, TextRange::at(TextSize::zero(), point));
103103
/// ```
104104
#[inline]
105-
pub const fn up_to(end: TextSize) -> TextRange {
106-
let start = TextSize::zero();
107-
TextRange { start, end }
105+
pub fn up_to(end: TextSize) -> TextRange {
106+
TextRange {
107+
start: 0.into(),
108+
end,
109+
}
108110
}
109111
}
110112

src/size.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,11 @@ impl TextSize {
5353
pub fn of<T: TextLen>(text: T) -> TextSize {
5454
text.text_len()
5555
}
56-
57-
/// A size of zero.
58-
///
59-
/// This is equivalent to `TextSize::default()` or [`TextSize::MIN`],
60-
/// but is more explicit on intent.
61-
#[inline]
62-
pub const fn zero() -> TextSize {
63-
TextSize { raw: 0 }
64-
}
6556
}
6657

6758
/// Methods to act like a primitive integer type, where reasonably applicable.
6859
// Last updated for parity with Rust 1.42.0.
6960
impl TextSize {
70-
/// The smallest representable text size. (`u32::MIN`)
71-
pub const MIN: TextSize = TextSize { raw: u32::MIN };
72-
/// The largest representable text size. (`u32::MAX`)
73-
pub const MAX: TextSize = TextSize { raw: u32::MAX };
74-
7561
/// Checked addition. Returns `None` if overflow occurred.
7662
#[inline]
7763
pub fn checked_add(self, rhs: TextSize) -> Option<TextSize> {
@@ -172,6 +158,6 @@ where
172158
{
173159
#[inline]
174160
fn sum<I: Iterator<Item = A>>(iter: I) -> TextSize {
175-
iter.fold(TextSize::zero(), Add::add)
161+
iter.fold(0.into(), Add::add)
176162
}
177163
}

src/traits.rs

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use {
2-
crate::TextSize,
3-
std::{borrow::Cow, convert::TryInto, rc::Rc, sync::Arc},
4-
};
1+
use {crate::TextSize, std::convert::TryInto};
52

63
use priv_in_pub::Sealed;
74
mod priv_in_pub {
@@ -22,47 +19,18 @@ impl TextLen for &'_ str {
2219
}
2320
}
2421

25-
impl Sealed for char {}
26-
impl TextLen for char {
22+
impl Sealed for &'_ String {}
23+
impl TextLen for &'_ String {
2724
#[inline]
2825
fn text_len(self) -> TextSize {
29-
(self.len_utf8() as u32).into()
26+
self.as_str().text_len()
3027
}
3128
}
3229

33-
impl<D> Sealed for &'_ D where D: TextLen + Copy {}
34-
impl<D> TextLen for &'_ D
35-
where
36-
D: TextLen + Copy,
37-
{
30+
impl Sealed for char {}
31+
impl TextLen for char {
32+
#[inline]
3833
fn text_len(self) -> TextSize {
39-
D::text_len(*self)
34+
(self.len_utf8() as u32).into()
4035
}
4136
}
42-
43-
// Because we could not find a smart blanket impl to do this automatically and
44-
// cleanly (rust-analyzer/text-size#36), just provide a bunch of manual impls.
45-
// If a standard type fits in this macro and you need it to impl TextLen, just
46-
// open a PR and we are likely to accept it. Or convince Rust to deref to &str.
47-
macro_rules! impl_textlen_for_string {
48-
($($ty:ty),+ $(,)?) => {$(
49-
impl Sealed for $ty {}
50-
impl TextLen for $ty {
51-
#[inline]
52-
fn text_len(self) -> TextSize {
53-
<&str>::text_len(self)
54-
}
55-
}
56-
)+};
57-
}
58-
59-
impl_textlen_for_string! {
60-
&Box<str>,
61-
&String,
62-
&Cow<'_, str>,
63-
&Cow<'_, String>,
64-
&Arc<str>,
65-
&Arc<String>,
66-
&Rc<str>,
67-
&Rc<String>,
68-
}

0 commit comments

Comments
 (0)