Struct Button

Source
pub struct Button { /* private fields */ }
Available on crate feature ev3 only.
Expand description

Ev3 brick button handler. Opens the corresponding /dev/input file handlers.

This implementation depends on the availability of the EVIOCGKEY ioctl to be able to read the button state buffer. See Linux kernel source in /include/uapi/linux/input.h for details.

use ev3dev_lang_rust::Button;
use std::thread;
use std::time::Duration;

let mut button = Button::new()?;

button.set_down_handler(|is_pressed| {
    println!("Is 'down' pressed: {is_pressed}");
});

loop {
    button.process();

    println!("Is 'up' pressed: {}", button.is_up());
    println!("Pressed buttons: {:?}", button.get_pressed_buttons());

    thread::sleep(Duration::from_millis(100));
}

Implementations§

Source§

impl Button

Source

pub fn new() -> Ev3Result<Self>

Ev3 brick button handler. Opens the corresponding /dev/input file handlers.

Examples found in repository?
examples/buttons.rs (line 6)
5fn main() -> Ev3Result<()> {
6    let button = Button::new()?;
7
8    loop {
9        button.process();
10
11        println!(
12            "{}, {}, {}, {}, {}, {}",
13            button.is_up(),
14            button.is_down(),
15            button.is_left(),
16            button.is_right(),
17            button.is_enter(),
18            button.is_backspace(),
19        );
20        println!("{:?}", button.get_pressed_buttons());
21
22        std::thread::sleep(std::time::Duration::from_secs(1));
23    }
24}
More examples
Hide additional examples
examples/button_handlers.rs (line 6)
5fn main() -> Ev3Result<()> {
6    let mut button = Button::new()?;
7
8    button.set_change_handler(|pressed_buttons| println!("Pressed buttons: {:?}", pressed_buttons));
9
10    button.set_up_handler(|is_pressed| println!("Button 'up' is pressed: {}", is_pressed));
11    button.set_down_handler(|is_pressed| println!("Button 'down' is pressed: {}", is_pressed));
12    button.set_left_handler(|is_pressed| println!("Button 'left' is pressed: {}", is_pressed));
13    button.set_right_handler(|is_pressed| println!("Button 'right' is pressed: {}", is_pressed));
14    button.set_enter_handler(|is_pressed| println!("Button 'enter' is pressed: {}", is_pressed));
15    button.set_backspace_handler(|is_pressed| {
16        println!("Button 'backspace' is pressed: {}", is_pressed)
17    });
18    button.set_backspace_handler(|is_pressed| {
19        println!("Button 'backspace' is pressed: {}", is_pressed)
20    });
21
22    loop {
23        button.process();
24        std::thread::sleep(std::time::Duration::from_millis(100));
25    }
26}
Source

pub fn process(&self)

Check for currently pressed buttons. If the new state differs from the old state, call the appropriate button event handlers.

use ev3dev_lang_rust::Button;
use std::thread;
use std::time::Duration;

let mut button = Button::new()?;

button.set_down_handler(|is_pressed| {
    println!("Is 'down' pressed: {is_pressed}");
});

loop {
    button.process();

    println!("Is 'up' pressed: {}", button.is_up());
    println!("Pressed buttons: {:?}", button.get_pressed_buttons());

    thread::sleep(Duration::from_millis(100));
}
Examples found in repository?
examples/buttons.rs (line 9)
5fn main() -> Ev3Result<()> {
6    let button = Button::new()?;
7
8    loop {
9        button.process();
10
11        println!(
12            "{}, {}, {}, {}, {}, {}",
13            button.is_up(),
14            button.is_down(),
15            button.is_left(),
16            button.is_right(),
17            button.is_enter(),
18            button.is_backspace(),
19        );
20        println!("{:?}", button.get_pressed_buttons());
21
22        std::thread::sleep(std::time::Duration::from_secs(1));
23    }
24}
More examples
Hide additional examples
examples/button_handlers.rs (line 23)
5fn main() -> Ev3Result<()> {
6    let mut button = Button::new()?;
7
8    button.set_change_handler(|pressed_buttons| println!("Pressed buttons: {:?}", pressed_buttons));
9
10    button.set_up_handler(|is_pressed| println!("Button 'up' is pressed: {}", is_pressed));
11    button.set_down_handler(|is_pressed| println!("Button 'down' is pressed: {}", is_pressed));
12    button.set_left_handler(|is_pressed| println!("Button 'left' is pressed: {}", is_pressed));
13    button.set_right_handler(|is_pressed| println!("Button 'right' is pressed: {}", is_pressed));
14    button.set_enter_handler(|is_pressed| println!("Button 'enter' is pressed: {}", is_pressed));
15    button.set_backspace_handler(|is_pressed| {
16        println!("Button 'backspace' is pressed: {}", is_pressed)
17    });
18    button.set_backspace_handler(|is_pressed| {
19        println!("Button 'backspace' is pressed: {}", is_pressed)
20    });
21
22    loop {
23        button.process();
24        std::thread::sleep(std::time::Duration::from_millis(100));
25    }
26}
Source

pub fn get_pressed_buttons(&self) -> HashSet<String>

Get all pressed buttons by name.

use ev3dev_lang_rust::Button;
use std::thread;
use std::time::Duration;

let button = Button::new()?;

loop {
    button.process();
    println!("Pressed buttons: {:?}", button.get_pressed_buttons());
    thread::sleep(Duration::from_millis(100));
}
Examples found in repository?
examples/buttons.rs (line 20)
5fn main() -> Ev3Result<()> {
6    let button = Button::new()?;
7
8    loop {
9        button.process();
10
11        println!(
12            "{}, {}, {}, {}, {}, {}",
13            button.is_up(),
14            button.is_down(),
15            button.is_left(),
16            button.is_right(),
17            button.is_enter(),
18            button.is_backspace(),
19        );
20        println!("{:?}", button.get_pressed_buttons());
21
22        std::thread::sleep(std::time::Duration::from_secs(1));
23    }
24}
Source

pub fn set_change_handler( &mut self, handler: impl Fn(HashSet<String>) + 'static, )

Set an event handler, that is called by process() if any button state changes. Has a set of all pressed buttons as parameter.

use ev3dev_lang_rust::Button;
use std::thread;
use std::time::Duration;

let mut button = Button::new()?;

button.set_change_handler(|pressed_buttons| {
    println!("pressed buttons: {:?}", pressed_buttons);
});

loop {
    button.process();
    thread::sleep(Duration::from_millis(100));
}
Examples found in repository?
examples/button_handlers.rs (line 8)
5fn main() -> Ev3Result<()> {
6    let mut button = Button::new()?;
7
8    button.set_change_handler(|pressed_buttons| println!("Pressed buttons: {:?}", pressed_buttons));
9
10    button.set_up_handler(|is_pressed| println!("Button 'up' is pressed: {}", is_pressed));
11    button.set_down_handler(|is_pressed| println!("Button 'down' is pressed: {}", is_pressed));
12    button.set_left_handler(|is_pressed| println!("Button 'left' is pressed: {}", is_pressed));
13    button.set_right_handler(|is_pressed| println!("Button 'right' is pressed: {}", is_pressed));
14    button.set_enter_handler(|is_pressed| println!("Button 'enter' is pressed: {}", is_pressed));
15    button.set_backspace_handler(|is_pressed| {
16        println!("Button 'backspace' is pressed: {}", is_pressed)
17    });
18    button.set_backspace_handler(|is_pressed| {
19        println!("Button 'backspace' is pressed: {}", is_pressed)
20    });
21
22    loop {
23        button.process();
24        std::thread::sleep(std::time::Duration::from_millis(100));
25    }
26}
Source

pub fn remove_change_handler(&mut self)

Removes the change event handler.

Source

pub fn is_up(&self) -> bool

Check if the up button is pressed.

use ev3dev_lang_rust::Button;
use std::thread;
use std::time::Duration;

let button = Button::new()?;

loop {
    button.process();
    println!("Is 'up' pressed: {}", button.is_up());
    thread::sleep(Duration::from_millis(100));
}
Examples found in repository?
examples/buttons.rs (line 13)
5fn main() -> Ev3Result<()> {
6    let button = Button::new()?;
7
8    loop {
9        button.process();
10
11        println!(
12            "{}, {}, {}, {}, {}, {}",
13            button.is_up(),
14            button.is_down(),
15            button.is_left(),
16            button.is_right(),
17            button.is_enter(),
18            button.is_backspace(),
19        );
20        println!("{:?}", button.get_pressed_buttons());
21
22        std::thread::sleep(std::time::Duration::from_secs(1));
23    }
24}
Source

pub fn set_up_handler(&mut self, handler: impl Fn(bool) + 'static)

Set an event handler, that is called by process() if the pressed state of the up button changes.

use ev3dev_lang_rust::Button;
use std::thread;
use std::time::Duration;

let mut button = Button::new()?;

button.set_up_handler(|is_pressed| {
    println!("Is 'up' pressed: {}", is_pressed);
});

loop {
    button.process();
    thread::sleep(Duration::from_millis(100));
}
Examples found in repository?
examples/button_handlers.rs (line 10)
5fn main() -> Ev3Result<()> {
6    let mut button = Button::new()?;
7
8    button.set_change_handler(|pressed_buttons| println!("Pressed buttons: {:?}", pressed_buttons));
9
10    button.set_up_handler(|is_pressed| println!("Button 'up' is pressed: {}", is_pressed));
11    button.set_down_handler(|is_pressed| println!("Button 'down' is pressed: {}", is_pressed));
12    button.set_left_handler(|is_pressed| println!("Button 'left' is pressed: {}", is_pressed));
13    button.set_right_handler(|is_pressed| println!("Button 'right' is pressed: {}", is_pressed));
14    button.set_enter_handler(|is_pressed| println!("Button 'enter' is pressed: {}", is_pressed));
15    button.set_backspace_handler(|is_pressed| {
16        println!("Button 'backspace' is pressed: {}", is_pressed)
17    });
18    button.set_backspace_handler(|is_pressed| {
19        println!("Button 'backspace' is pressed: {}", is_pressed)
20    });
21
22    loop {
23        button.process();
24        std::thread::sleep(std::time::Duration::from_millis(100));
25    }
26}
Source

pub fn remove_up_handler(&mut self)

Removes the event handler of the up button.

Source

pub fn is_down(&self) -> bool

Check if the down button is pressed.

use ev3dev_lang_rust::Button;
use std::thread;
use std::time::Duration;

let button = Button::new()?;

loop {
    button.process();
    println!("Is 'down' pressed: {}", button.is_down());
    thread::sleep(Duration::from_millis(100));
}
Examples found in repository?
examples/buttons.rs (line 14)
5fn main() -> Ev3Result<()> {
6    let button = Button::new()?;
7
8    loop {
9        button.process();
10
11        println!(
12            "{}, {}, {}, {}, {}, {}",
13            button.is_up(),
14            button.is_down(),
15            button.is_left(),
16            button.is_right(),
17            button.is_enter(),
18            button.is_backspace(),
19        );
20        println!("{:?}", button.get_pressed_buttons());
21
22        std::thread::sleep(std::time::Duration::from_secs(1));
23    }
24}
Source

pub fn set_down_handler(&mut self, handler: impl Fn(bool) + 'static)

Set an event handler, that is called by process() if the pressed state of the down button changes.

use ev3dev_lang_rust::Button;
use std::thread;
use std::time::Duration;

let mut button = Button::new()?;

button.set_down_handler(|is_pressed| {
    println!("Is 'down' pressed: {}", is_pressed);
});

loop {
    button.process();
    thread::sleep(Duration::from_millis(100));
}
Examples found in repository?
examples/button_handlers.rs (line 11)
5fn main() -> Ev3Result<()> {
6    let mut button = Button::new()?;
7
8    button.set_change_handler(|pressed_buttons| println!("Pressed buttons: {:?}", pressed_buttons));
9
10    button.set_up_handler(|is_pressed| println!("Button 'up' is pressed: {}", is_pressed));
11    button.set_down_handler(|is_pressed| println!("Button 'down' is pressed: {}", is_pressed));
12    button.set_left_handler(|is_pressed| println!("Button 'left' is pressed: {}", is_pressed));
13    button.set_right_handler(|is_pressed| println!("Button 'right' is pressed: {}", is_pressed));
14    button.set_enter_handler(|is_pressed| println!("Button 'enter' is pressed: {}", is_pressed));
15    button.set_backspace_handler(|is_pressed| {
16        println!("Button 'backspace' is pressed: {}", is_pressed)
17    });
18    button.set_backspace_handler(|is_pressed| {
19        println!("Button 'backspace' is pressed: {}", is_pressed)
20    });
21
22    loop {
23        button.process();
24        std::thread::sleep(std::time::Duration::from_millis(100));
25    }
26}
Source

pub fn remove_down_handler(&mut self)

Removes the event handler of the down button.

Source

pub fn is_left(&self) -> bool

Check if the left button is pressed.

use ev3dev_lang_rust::Button;
use std::thread;
use std::time::Duration;

let button = Button::new()?;

loop {
    button.process();
    println!("Is 'left' pressed: {}", button.is_left());
    thread::sleep(Duration::from_millis(100));
}
Examples found in repository?
examples/buttons.rs (line 15)
5fn main() -> Ev3Result<()> {
6    let button = Button::new()?;
7
8    loop {
9        button.process();
10
11        println!(
12            "{}, {}, {}, {}, {}, {}",
13            button.is_up(),
14            button.is_down(),
15            button.is_left(),
16            button.is_right(),
17            button.is_enter(),
18            button.is_backspace(),
19        );
20        println!("{:?}", button.get_pressed_buttons());
21
22        std::thread::sleep(std::time::Duration::from_secs(1));
23    }
24}
Source

pub fn set_left_handler(&mut self, handler: impl Fn(bool) + 'static)

Set an event handler, that is called by process() if the pressed state of the left button changes.

use ev3dev_lang_rust::Button;
use std::thread;
use std::time::Duration;

let mut button = Button::new()?;

button.set_left_handler(|is_pressed| {
    println!("Is 'left' pressed: {}", is_pressed);
});

loop {
    button.process();
    thread::sleep(Duration::from_millis(100));
}
Examples found in repository?
examples/button_handlers.rs (line 12)
5fn main() -> Ev3Result<()> {
6    let mut button = Button::new()?;
7
8    button.set_change_handler(|pressed_buttons| println!("Pressed buttons: {:?}", pressed_buttons));
9
10    button.set_up_handler(|is_pressed| println!("Button 'up' is pressed: {}", is_pressed));
11    button.set_down_handler(|is_pressed| println!("Button 'down' is pressed: {}", is_pressed));
12    button.set_left_handler(|is_pressed| println!("Button 'left' is pressed: {}", is_pressed));
13    button.set_right_handler(|is_pressed| println!("Button 'right' is pressed: {}", is_pressed));
14    button.set_enter_handler(|is_pressed| println!("Button 'enter' is pressed: {}", is_pressed));
15    button.set_backspace_handler(|is_pressed| {
16        println!("Button 'backspace' is pressed: {}", is_pressed)
17    });
18    button.set_backspace_handler(|is_pressed| {
19        println!("Button 'backspace' is pressed: {}", is_pressed)
20    });
21
22    loop {
23        button.process();
24        std::thread::sleep(std::time::Duration::from_millis(100));
25    }
26}
Source

pub fn remove_left_handler(&mut self)

Removes the event handler of the left button.

Source

pub fn is_right(&self) -> bool

Check if the right button is pressed.

use ev3dev_lang_rust::Button;
use std::thread;
use std::time::Duration;

let button = Button::new()?;

loop {
    button.process();
    println!("Is 'right' pressed: {}", button.is_right());
    thread::sleep(Duration::from_millis(100));
}
Examples found in repository?
examples/buttons.rs (line 16)
5fn main() -> Ev3Result<()> {
6    let button = Button::new()?;
7
8    loop {
9        button.process();
10
11        println!(
12            "{}, {}, {}, {}, {}, {}",
13            button.is_up(),
14            button.is_down(),
15            button.is_left(),
16            button.is_right(),
17            button.is_enter(),
18            button.is_backspace(),
19        );
20        println!("{:?}", button.get_pressed_buttons());
21
22        std::thread::sleep(std::time::Duration::from_secs(1));
23    }
24}
Source

pub fn set_right_handler(&mut self, handler: impl Fn(bool) + 'static)

Set an event handler, that is called by process() if the pressed state of the right button changes.

use ev3dev_lang_rust::Button;
use std::thread;
use std::time::Duration;

let mut button = Button::new()?;

button.set_right_handler(|is_pressed| {
    println!("Is 'right' pressed: {}", is_pressed);
});

loop {
    button.process();
    thread::sleep(Duration::from_millis(100));
}
Examples found in repository?
examples/button_handlers.rs (line 13)
5fn main() -> Ev3Result<()> {
6    let mut button = Button::new()?;
7
8    button.set_change_handler(|pressed_buttons| println!("Pressed buttons: {:?}", pressed_buttons));
9
10    button.set_up_handler(|is_pressed| println!("Button 'up' is pressed: {}", is_pressed));
11    button.set_down_handler(|is_pressed| println!("Button 'down' is pressed: {}", is_pressed));
12    button.set_left_handler(|is_pressed| println!("Button 'left' is pressed: {}", is_pressed));
13    button.set_right_handler(|is_pressed| println!("Button 'right' is pressed: {}", is_pressed));
14    button.set_enter_handler(|is_pressed| println!("Button 'enter' is pressed: {}", is_pressed));
15    button.set_backspace_handler(|is_pressed| {
16        println!("Button 'backspace' is pressed: {}", is_pressed)
17    });
18    button.set_backspace_handler(|is_pressed| {
19        println!("Button 'backspace' is pressed: {}", is_pressed)
20    });
21
22    loop {
23        button.process();
24        std::thread::sleep(std::time::Duration::from_millis(100));
25    }
26}
Source

pub fn remove_right_handler(&mut self)

Removes the event handler of the right button.

Source

pub fn is_enter(&self) -> bool

Check if the enter button is pressed.

use ev3dev_lang_rust::Button;
use std::thread;
use std::time::Duration;

let button = Button::new()?;

loop {
    button.process();
    println!("Is 'enter' pressed: {}", button.is_enter());
    thread::sleep(Duration::from_millis(100));
}
Examples found in repository?
examples/buttons.rs (line 17)
5fn main() -> Ev3Result<()> {
6    let button = Button::new()?;
7
8    loop {
9        button.process();
10
11        println!(
12            "{}, {}, {}, {}, {}, {}",
13            button.is_up(),
14            button.is_down(),
15            button.is_left(),
16            button.is_right(),
17            button.is_enter(),
18            button.is_backspace(),
19        );
20        println!("{:?}", button.get_pressed_buttons());
21
22        std::thread::sleep(std::time::Duration::from_secs(1));
23    }
24}
Source

pub fn set_enter_handler(&mut self, handler: impl Fn(bool) + 'static)

Set an event handler, that is called by process() if the pressed state of the enter button changes.

use ev3dev_lang_rust::Button;
use std::thread;
use std::time::Duration;

let mut button = Button::new()?;

button.set_enter_handler(|is_pressed| {
    println!("Is 'enter' pressed: {}", is_pressed);
});

loop {
    button.process();
    thread::sleep(Duration::from_millis(100));
}
Examples found in repository?
examples/button_handlers.rs (line 14)
5fn main() -> Ev3Result<()> {
6    let mut button = Button::new()?;
7
8    button.set_change_handler(|pressed_buttons| println!("Pressed buttons: {:?}", pressed_buttons));
9
10    button.set_up_handler(|is_pressed| println!("Button 'up' is pressed: {}", is_pressed));
11    button.set_down_handler(|is_pressed| println!("Button 'down' is pressed: {}", is_pressed));
12    button.set_left_handler(|is_pressed| println!("Button 'left' is pressed: {}", is_pressed));
13    button.set_right_handler(|is_pressed| println!("Button 'right' is pressed: {}", is_pressed));
14    button.set_enter_handler(|is_pressed| println!("Button 'enter' is pressed: {}", is_pressed));
15    button.set_backspace_handler(|is_pressed| {
16        println!("Button 'backspace' is pressed: {}", is_pressed)
17    });
18    button.set_backspace_handler(|is_pressed| {
19        println!("Button 'backspace' is pressed: {}", is_pressed)
20    });
21
22    loop {
23        button.process();
24        std::thread::sleep(std::time::Duration::from_millis(100));
25    }
26}
Source

pub fn remove_enter_handler(&mut self)

Removes the event handler of the enter button.

Source

pub fn is_backspace(&self) -> bool

Check if the backspace button is pressed.

use ev3dev_lang_rust::Button;
use std::thread;
use std::time::Duration;

let button = Button::new()?;

loop {
    button.process();
    println!("Is 'backspace' pressed: {}", button.is_backspace());
    thread::sleep(Duration::from_millis(100));
}
Examples found in repository?
examples/buttons.rs (line 18)
5fn main() -> Ev3Result<()> {
6    let button = Button::new()?;
7
8    loop {
9        button.process();
10
11        println!(
12            "{}, {}, {}, {}, {}, {}",
13            button.is_up(),
14            button.is_down(),
15            button.is_left(),
16            button.is_right(),
17            button.is_enter(),
18            button.is_backspace(),
19        );
20        println!("{:?}", button.get_pressed_buttons());
21
22        std::thread::sleep(std::time::Duration::from_secs(1));
23    }
24}
Source

pub fn set_backspace_handler(&mut self, handler: impl Fn(bool) + 'static)

Set an event handler, that is called by process() if the pressed state of the backspace button changes.

use ev3dev_lang_rust::Button;
use std::thread;
use std::time::Duration;

let mut button = Button::new()?;

button.set_backspace_handler(|is_pressed| {
    println!("Is 'backspace' pressed: {}", is_pressed);
});

loop {
    button.process();
    thread::sleep(Duration::from_millis(100));
}
Examples found in repository?
examples/button_handlers.rs (lines 15-17)
5fn main() -> Ev3Result<()> {
6    let mut button = Button::new()?;
7
8    button.set_change_handler(|pressed_buttons| println!("Pressed buttons: {:?}", pressed_buttons));
9
10    button.set_up_handler(|is_pressed| println!("Button 'up' is pressed: {}", is_pressed));
11    button.set_down_handler(|is_pressed| println!("Button 'down' is pressed: {}", is_pressed));
12    button.set_left_handler(|is_pressed| println!("Button 'left' is pressed: {}", is_pressed));
13    button.set_right_handler(|is_pressed| println!("Button 'right' is pressed: {}", is_pressed));
14    button.set_enter_handler(|is_pressed| println!("Button 'enter' is pressed: {}", is_pressed));
15    button.set_backspace_handler(|is_pressed| {
16        println!("Button 'backspace' is pressed: {}", is_pressed)
17    });
18    button.set_backspace_handler(|is_pressed| {
19        println!("Button 'backspace' is pressed: {}", is_pressed)
20    });
21
22    loop {
23        button.process();
24        std::thread::sleep(std::time::Duration::from_millis(100));
25    }
26}
Source

pub fn remove_backspace_handler(&mut self)

Removes the event handler of the backspace button.

Trait Implementations§

Source§

impl Clone for Button

Source§

fn clone(&self) -> Button

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Button

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Button

§

impl !RefUnwindSafe for Button

§

impl !Send for Button

§

impl !Sync for Button

§

impl Unpin for Button

§

impl !UnwindSafe for Button

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.