Trait MultiPrint

Source
pub trait MultiPrint: ToString {
    // Provided method
    fn times(&self, n: usize, sep: char) -> String { ... }
}
Expand description

This MultiPrint trait exposes a default implementation of the times() method

By default, the times method is auto-implemented for the String type

Provided Methods§

Source

fn times(&self, n: usize, sep: char) -> String

Examples found in repository?
examples/sample_headers.rs (line 5)
3fn main() {
4    let s = String::from("Echo..");
5    println!("{}", s.times(5, ' '));
6
7    assert_eq!(s.times(5, ' '), "Echo.. Echo.. Echo.. Echo.. Echo..");
8    assert_eq!("Hello!".to_string().times(2, ' '), "Hello! Hello!");
9
10    // this will output:
11    //
12    //   Header 1
13    //   --------
14    //
15    println!("{}\n", "Header 1".to_string().underline('-'));
16
17    // this will output:
18    //
19    //   --------
20    //   Header 1
21    //
22    println!("{}\n", "Header 1".to_string().overline('-'));
23
24    // this will output:
25    //
26    //   ________
27    //   Header 1
28    //   ========
29    //
30    println!("{}\n", "Header 1".to_string().outline('_', '='));
31
32    // this will output:
33    //
34    //   ------------
35    //   | Header 1 |
36    //   ------------
37    //
38    println!("{}", "Header 1".to_string().border('-', '|'));
39}

Implementations on Foreign Types§

Source§

impl MultiPrint for String

Implementors§