pub trait Stringy:
Index<Range<usize>, Output = str>
+ Index<RangeFrom<usize>, Output = str>
+ Deref<Target = str>
+ Extend<char> {
// Required methods
fn push(&mut self, ch: char);
fn push_str(&mut self, string: &str);
fn pop(&mut self) -> Option<char>;
fn truncate(&mut self, new_len: usize);
fn replace_range<R>(&mut self, range: R, replace_with: &str)
where R: RangeBounds<usize>;
}
Expand description
A target for sanitisation: essentially the subset of String
functionality used.
It might have been nice to use something like Read + Write + Seek
instead, but the need to
delete things after writing means that you need still more, and in the end it’s much easier to
treat it as a string.
I’ve provided implementations for String
(if the alloc feature is enabled, which it is by
default) and tinyvec_string::ArrayString
(if the tinyvec_string feature is enabled),
but there’s nothing preventing you from implementing it on other similar string types.
Required Methods§
fn push(&mut self, ch: char)
fn push_str(&mut self, string: &str)
fn pop(&mut self) -> Option<char>
fn truncate(&mut self, new_len: usize)
fn replace_range<R>(&mut self, range: R, replace_with: &str)where
R: RangeBounds<usize>,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<A: ByteArray> Stringy for ArrayString<A>
Available on crate feature tinyvec_string
only.
impl<A: ByteArray> Stringy for ArrayString<A>
Available on crate feature
tinyvec_string
only.