pub trait BoundedDisplay {
// Required method
fn fmt(&self, f: &mut impl Write, n: Option<usize>) -> Result;
// Provided methods
fn fmt_bounded(&self, f: &mut impl Write, n: usize) -> Result { ... }
fn fmt_unbounded(&self, f: &mut impl Write) -> Result { ... }
}
Expand description
Like Display
, 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 fmt_bounded(&self, f: &mut impl Write, n: usize) -> Result
fn fmt_bounded(&self, f: &mut impl Write, n: usize) -> Result
Convenience method, equivalent to fmt()
with n
as Some
.
You should generally not re-implement this, just use the default implementation.
Sourcefn fmt_unbounded(&self, f: &mut impl Write) -> Result
fn fmt_unbounded(&self, f: &mut impl Write) -> Result
Convenience method, equivalent to fmt()
with n
as None
.
You should generally not re-implement this, just use the default implementation.
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.