pub trait StringExtT: Sized {
// Required method
fn push_to_string(self, string: &mut Vec<u8>);
// Provided methods
fn push_to_string_with_separator(
self,
string: &mut Vec<u8>,
separator: impl SeparatorT,
) { ... }
fn to_string_ext(self) -> String { ... }
fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String { ... }
}
Expand description
Trait for pushing any value that can be converted into str to StringExt
If needed, you can implement this trait for your own type.
The type we support currently:
-
[
()
]: will be a no-op -
bool
: stringtrue
orfalse
. -
Any (smart) pointer that implements
ops::Deref
with targetstr
.Since the compiler complains with MAYBE IMPLEMENTED BY UPSTREAM, we have to do so manually.
- &
str
String
Rc<str>
Rc<String>
Arc<str>
Arc<String>
Box<String>
// Actually meanlessCow<str>
- &
-
Numbers, see
NumStr
-
Hex string, see
HexStr
, includingconst_hex::Buffer
-
Slice of any type that implements
StringExtT
, including &[[T]] or [[T; N]], -
Vec
of any type that implementsStringExtT
-
Iterator with item that implements
StringExtT
Since the compiler complains with MAYBE IMPLEMENTED BY UPSTREAM, we have to do so manually.
-
Box
of any type that implementsStringExtT
-
Option
of any type that implementsStringExtT
-
Tuple of any type that implements
StringExtT
-
Any type that implements
Copy
, just copy it.Since the compiler complains with MAYBE IMPLEMENTED BY UPSTREAM, we have to do so manually.
Required Methods§
Sourcefn push_to_string(self, string: &mut Vec<u8>)
fn push_to_string(self, string: &mut Vec<u8>)
Push the value to the string.
Provided Methods§
Sourcefn push_to_string_with_separator(
self,
string: &mut Vec<u8>,
separator: impl SeparatorT,
)
fn push_to_string_with_separator( self, string: &mut Vec<u8>, separator: impl SeparatorT, )
Push the value to the string with a separator.
! Separator should implement SeparatorT
Sourcefn to_string_ext(self) -> String
fn to_string_ext(self) -> String
Encode the value to the string.
Sourcefn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
Push the value to the string with separator
! Separator should implement SeparatorT
.
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.