From 51e33438b117ea0facdceb0f2fc3291494045f13 Mon Sep 17 00:00:00 2001 From: TheVeryDarkness <3266343194@qq.com> Date: Sat, 12 Oct 2024 10:58:29 +0800 Subject: [PATCH] Update documentation about `sep_by!` in lib.rs --- src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 3fb8a32..cbf106b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -296,11 +296,21 @@ //! //! ```rust //! use iof::{sep_by, SepBy}; +//! use std::f64::consts::*; //! //! let v = vec![1.0, 2.1, 3.2]; //! let s = sep_by!(&v, ", "); //! assert_eq!(format!("{s:?}"), "1.0, 2.1, 3.2"); //! +//! let v = vec!["Alice", "Bob", "Charlie"]; +//! let s = sep_by!(&v, ";"); +//! assert_eq!(format!("{s:>10}"), " Alice; Bob; Charlie"); +//! assert_eq!(format!("{s:<10}"), "Alice ;Bob ;Charlie "); +//! +//! let v = vec![E, PI, FRAC_1_PI, LN_2, LN_10, SQRT_2]; +//! let s = sep_by!(&v, ""); +//! assert_eq!(format!("{s:15.7}"), " 2.7182818 3.1415927 0.3183099 0.6931472 2.3025851 1.4142136"); +//! //! let v = vec![3735928559u32, 3405691582u32, 3405709037u32, 3435973836u32, 3452816845u32]; //! let s = sep_by!(&v, " "); //! assert_eq!(format!("{s:x}"), "deadbeef cafebabe cafefeed cccccccc cdcdcdcd");