1
1
use core:: { fmt, iter:: FusedIterator , str:: Chars } ;
2
2
3
- use super :: String ;
3
+ use super :: StringView ;
4
4
5
5
/// A draining iterator for `String`.
6
6
///
7
- /// This struct is created by the [`drain`] method on [`String`]. See its
7
+ /// This struct is created by the [`drain`] method on [`crate:: String`]. See its
8
8
/// documentation for more.
9
9
///
10
- /// [`drain`]: String::drain
11
- pub struct Drain < ' a , const N : usize > {
10
+ /// [`drain`]: crate:: String::drain
11
+ pub struct Drain < ' a > {
12
12
/// Will be used as &'a mut String in the destructor
13
- pub ( super ) string : * mut String < N > ,
14
- /// Start of part to remove
13
+ pub ( super ) string : * mut StringView ,
14
+ /// Stast of part to remove
15
15
pub ( super ) start : usize ,
16
16
/// End of part to remove
17
17
pub ( super ) end : usize ,
18
18
/// Current remaining range to remove
19
19
pub ( super ) iter : Chars < ' a > ,
20
20
}
21
21
22
- impl < const N : usize > fmt:: Debug for Drain < ' _ , N > {
22
+ impl fmt:: Debug for Drain < ' _ > {
23
23
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
24
24
f. debug_tuple ( "Drain" ) . field ( & self . as_str ( ) ) . finish ( )
25
25
}
26
26
}
27
27
28
- unsafe impl < const N : usize > Sync for Drain < ' _ , N > { }
29
- unsafe impl < const N : usize > Send for Drain < ' _ , N > { }
28
+ unsafe impl Sync for Drain < ' _ > { }
29
+ unsafe impl Send for Drain < ' _ > { }
30
30
31
- impl < const N : usize > Drop for Drain < ' _ , N > {
31
+ impl Drop for Drain < ' _ > {
32
32
fn drop ( & mut self ) {
33
33
unsafe {
34
34
// Use `Vec::drain`. “Reaffirm” the bounds checks to avoid
@@ -41,7 +41,7 @@ impl<const N: usize> Drop for Drain<'_, N> {
41
41
}
42
42
}
43
43
44
- impl < ' a , const N : usize > Drain < ' a , N > {
44
+ impl < ' a > Drain < ' a > {
45
45
/// Returns the remaining (sub)string of this iterator as a slice.
46
46
///
47
47
/// # Examples
@@ -61,19 +61,19 @@ impl<'a, const N: usize> Drain<'a, N> {
61
61
}
62
62
}
63
63
64
- impl < const N : usize > AsRef < str > for Drain < ' _ , N > {
64
+ impl AsRef < str > for Drain < ' _ > {
65
65
fn as_ref ( & self ) -> & str {
66
66
self . as_str ( )
67
67
}
68
68
}
69
69
70
- impl < const N : usize > AsRef < [ u8 ] > for Drain < ' _ , N > {
70
+ impl AsRef < [ u8 ] > for Drain < ' _ > {
71
71
fn as_ref ( & self ) -> & [ u8 ] {
72
72
self . as_str ( ) . as_bytes ( )
73
73
}
74
74
}
75
75
76
- impl < const N : usize > Iterator for Drain < ' _ , N > {
76
+ impl Iterator for Drain < ' _ > {
77
77
type Item = char ;
78
78
79
79
#[ inline]
@@ -91,18 +91,18 @@ impl<const N: usize> Iterator for Drain<'_, N> {
91
91
}
92
92
}
93
93
94
- impl < const N : usize > DoubleEndedIterator for Drain < ' _ , N > {
94
+ impl DoubleEndedIterator for Drain < ' _ > {
95
95
#[ inline]
96
96
fn next_back ( & mut self ) -> Option < char > {
97
97
self . iter . next_back ( )
98
98
}
99
99
}
100
100
101
- impl < const N : usize > FusedIterator for Drain < ' _ , N > { }
101
+ impl FusedIterator for Drain < ' _ > { }
102
102
103
103
#[ cfg( test) ]
104
104
mod tests {
105
- use super :: String ;
105
+ use crate :: String ;
106
106
107
107
#[ test]
108
108
fn drain_front ( ) {
0 commit comments