Trait BoundedToString

Source
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§

Source

fn to_string(&self, n: Option<usize>) -> String

Convert self to a String, truncating set elements or key-value pairs if necessary based on n

Provided Methods§

Source

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.

Source

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§

Source§

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.