Type Definition size::fmt::FormattableSize
source · [−]pub type FormattableSize<'a> = SizeFormatter<&'a Size>;
Expand description
A type that can be used to achieve greater control over how a Size
is formatted as
human-readable text, created by calling Size::format()
. The SizeFormatter
follows the
builder model and exposes a chaining API for configuration (via the .with_
functions).
After configuration, a FormattableSize
may be passed directly to the println!()
or
format!()
macros and their friends because it implements Display
, or
FormattableSize::to_string()
can be used to retrieve a String
containing the formatted
result.
Example:
use size::{Base, Size, Style};
let size = Size::from_mib(1.907349);
let text = size.format()
.with_base(Base::Base10)
.with_style(Style::Full)
.to_string();
assert_eq!(text.as_str(), "2.00 Megabytes");
Implementations
sourceimpl FormattableSize<'_>
impl FormattableSize<'_>
sourcepub fn to_string(&self) -> String
pub fn to_string(&self) -> String
Returns the formatted Size
as a String
, formatted according to the current state of the
SizeFormatter
instance as modified via with_style()
,
with_base()
, and co.