equal
deleted
inserted
replaced
65 pub trait SliceExt { |
65 pub trait SliceExt { |
66 fn trim_end(&self) -> &Self; |
66 fn trim_end(&self) -> &Self; |
67 fn trim_start(&self) -> &Self; |
67 fn trim_start(&self) -> &Self; |
68 fn trim(&self) -> &Self; |
68 fn trim(&self) -> &Self; |
69 fn drop_prefix(&self, needle: &Self) -> Option<&Self>; |
69 fn drop_prefix(&self, needle: &Self) -> Option<&Self>; |
|
70 fn split_2(&self, separator: u8) -> Option<(&[u8], &[u8])>; |
70 } |
71 } |
71 |
72 |
72 #[allow(clippy::trivially_copy_pass_by_ref)] |
73 #[allow(clippy::trivially_copy_pass_by_ref)] |
73 fn is_not_whitespace(c: &u8) -> bool { |
74 fn is_not_whitespace(c: &u8) -> bool { |
74 !(*c as char).is_whitespace() |
75 !(*c as char).is_whitespace() |
114 Some(&self[needle.len()..]) |
115 Some(&self[needle.len()..]) |
115 } else { |
116 } else { |
116 None |
117 None |
117 } |
118 } |
118 } |
119 } |
|
120 |
|
121 fn split_2(&self, separator: u8) -> Option<(&[u8], &[u8])> { |
|
122 let mut iter = self.splitn(2, |&byte| byte == separator); |
|
123 let a = iter.next()?; |
|
124 let b = iter.next()?; |
|
125 Some((a, b)) |
|
126 } |
119 } |
127 } |
120 |
128 |
121 pub trait Escaped { |
129 pub trait Escaped { |
122 /// Return bytes escaped for display to the user |
130 /// Return bytes escaped for display to the user |
123 fn escaped_bytes(&self) -> Vec<u8>; |
131 fn escaped_bytes(&self) -> Vec<u8>; |