Struct Moins

Source
pub struct Moins<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> Moins<'a>

Source

pub fn run(content: &'a mut String, options: Option<PagerOptions<'_>>)

run moins pager

Examples found in repository?
examples/simple.rs (line 7)
5fn main() {
6    let mut content = String::from("👋 🌎!");
7    Moins::run(&mut content, None);
8}
More examples
Hide additional examples
examples/colors.rs (line 28)
8fn main() {
9    let mut content = "A noir, E blanc, I rouge, U vert, O bleu, voyelles,
10Je dirai quelque jour vos naissances latentes.
11A, noir corset velu des mouches éclatantes
12Qui bombillent autour des puanteurs cruelles"
13        .to_owned();
14
15    let mut colors = HashMap::new();
16    colors.insert("A", Color::Black);
17    colors.insert("E", Color::White);
18    colors.insert("I", Color::Red);
19    colors.insert("U", Color::Green);
20    colors.insert("O", Color::Blue);
21
22    let options = PagerOptions {
23        colors,
24        search: false,
25        line_number: false,
26    };
27
28    Moins::run(&mut content, Some(options));
29}
examples/cli.rs (line 49)
17fn main() -> Result<()> {
18    let args: Vec<String> = env::args().collect();
19
20    let path = if args.len() > 1 {
21        Some(args[1].as_str())
22    } else {
23        None
24    };
25
26    let mut content = String::new();
27
28    let mut file = if let Some(path) = path {
29        File::open(path)?
30    } else {
31        panic!("expected an input file")
32    };
33
34    file.read_to_string(&mut content)?;
35
36    let mut colors = HashMap::new();
37    colors.insert("[[package]]", Color::Blue);
38    colors.insert("dependencies", Color::Magenta);
39    colors.insert("version", Color::LightRed);
40    colors.insert("name", Color::Cyan);
41    colors.insert("metadata", Color::Green);
42
43    let options = PagerOptions {
44        colors,
45        search: false,
46        line_number: false,
47    };
48
49    Moins::run(&mut content, Some(options));
50
51    Ok(())
52}

Auto Trait Implementations§

§

impl<'a> !Freeze for Moins<'a>

§

impl<'a> !RefUnwindSafe for Moins<'a>

§

impl<'a> Send for Moins<'a>

§

impl<'a> !Sync for Moins<'a>

§

impl<'a> Unpin for Moins<'a>

§

impl<'a> UnwindSafe for Moins<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.