pub trait BoundedToString {
// Required method
fn to_string(&self, n: Option<usize>) -> String;
// Provided methods
fn to_string_bounded(&self, n: usize) -> String { ... }
fn to_string_unbounded(&self) -> String { ... }
}
Expand description
Like ToString
, but optionally truncates embedded sets/records to n
elements/pairs, including recursively.
n
: the maximum number of set elements, or record key-value pairs, that
will be shown before eliding the rest with ..
.
None
means no bound.
Intended for error messages, to avoid very large/long error messages.
Required Methods§
Provided Methods§
Sourcefn to_string_bounded(&self, n: usize) -> String
fn to_string_bounded(&self, n: usize) -> String
Convenience method, equivalent to to_string()
with n
as Some
.
You should generally not re-implement this, just use the default implementation.
Sourcefn to_string_unbounded(&self) -> String
fn to_string_unbounded(&self) -> String
Convenience method, equivalent to to_string()
with n
as None
.
You should generally not re-implement this, just use the default implementation.
Implementors§
impl<T: BoundedDisplay> BoundedToString for T
Like the impl of ToString
for T: Display
in the standard library,
this impl of BoundedToString
for T: BoundedDisplay
panics if the BoundedDisplay
implementation returns an error, which would indicate an incorrect BoundedDisplay
implementation since fmt::Write
-ing to a String
never returns an error.