From d1b2d29528b7794b41e66fc2136e395a02f8529b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:59:35 +0200 Subject: Merging upstream version 1.73.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/humansize/examples/custom_options.rs | 10 ++++++++++ vendor/humansize/examples/sizes.rs | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 vendor/humansize/examples/custom_options.rs create mode 100644 vendor/humansize/examples/sizes.rs (limited to 'vendor/humansize/examples') diff --git a/vendor/humansize/examples/custom_options.rs b/vendor/humansize/examples/custom_options.rs new file mode 100644 index 000000000..dbfd72f87 --- /dev/null +++ b/vendor/humansize/examples/custom_options.rs @@ -0,0 +1,10 @@ +extern crate humansize; +use humansize::{format_size, FormatSizeOptions, DECIMAL}; + +fn main() { + // Create a new FormatSizeOptions struct starting from one of the defaults + let custom_options = FormatSizeOptions::from(DECIMAL).decimal_places(5); + + // Then use it + println!("{}", format_size(3024usize, custom_options)); +} diff --git a/vendor/humansize/examples/sizes.rs b/vendor/humansize/examples/sizes.rs new file mode 100644 index 000000000..72ba76616 --- /dev/null +++ b/vendor/humansize/examples/sizes.rs @@ -0,0 +1,16 @@ +extern crate humansize; + +use humansize::{format_size, format_size_i, SizeFormatter, ISizeFormatter, BINARY, DECIMAL, WINDOWS}; + +fn main() { + println!("{}", format_size(5456usize, BINARY)); + println!("{}", format_size(1024usize, DECIMAL)); + println!("{}", format_size(1000usize, WINDOWS)); + + println!("{}", format_size(1_023_654_123_654_u64, BINARY)); + println!("{}", format_size(123456789usize, DECIMAL)); + println!("{}", format_size_i(-123456789, WINDOWS)); + + println!("{}", SizeFormatter::new(1234u32, BINARY)); + println!("{}", ISizeFormatter::new(1234, BINARY)); +} -- cgit v1.2.3