pub trait Text<'a>:
Sized
+ Clone
+ 'a {
// Required methods
fn from_static_str(s: &'static str) -> Self;
fn as_str(&self) -> Cow<'_, str>;
// Provided methods
fn from_static_spaces(s: &'static str) -> Self { ... }
fn len(&self) -> usize { ... }
fn space() -> Self { ... }
fn newline() -> Self { ... }
fn comma_space() -> Self { ... }
}Expand description
Pretty printing can work with arbitrary text-like objects, as long as they implement this trait.
Required Methods§
Sourcefn from_static_str(s: &'static str) -> Self
fn from_static_str(s: &'static str) -> Self
Turn a &’static str into Self, without any further knowledge about it.
Used for a bunch of functions to give a default. Often not the most optimal or even desired implementation.
Provided Methods§
Sourcefn from_static_spaces(s: &'static str) -> Self
fn from_static_spaces(s: &'static str) -> Self
We foten insert spaces as a static str.
By default this is implemented with [from_static_str].
Sourcefn newline() -> Self
fn newline() -> Self
A newline character
By default this is implemented with [from_static_str].
Sourcefn comma_space() -> Self
fn comma_space() -> Self
A comma and space character
By default this is implemented with [from_static_str].
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.