Skip to main content

Color

Struct Color 

Source
pub struct Color(pub f32, pub f32, pub f32, pub f32);

Tuple Fields§

§0: f32§1: f32§2: f32§3: f32

Implementations§

Source§

impl Color

Color class

Source

pub fn new_alpha(r: f32, g: f32, b: f32, a: f32) -> Color

Create a color with the alpha

Source

pub fn new(r: f32, g: f32, b: f32) -> Color

Create a new color

Examples found in repository?
examples/event.rs (line 23)
15fn main() {
16    let mut window = Window::new(gust::WIDTH, gust::HEIGHT, "Hello");
17    let tex_dirt = Rc::new(Texture::from_path("examples/texture/Dirt.png").unwrap());
18    let event_handler = EventHandler::new(&window);
19    let mut sprites = HashMap::new();
20    sprites.insert("dirt_1", Sprite::from(&tex_dirt));
21    sprites.insert("dirt_2", Sprite::from(&tex_dirt));
22
23    window.set_clear_color(Color::new(0.0, 0.0, 1.0));
24    window.enable_cursor();
25    window.poll(None);
26    while window.is_open() {
27        window.poll_events();
28
29        for event in event_handler.fetch() {
30            event_process(event, &mut window, &mut sprites);
31        }
32
33        draw(&mut window, &mut sprites);
34    }
35}
More examples
Hide additional examples
examples/batch.rs (line 28)
15fn main() -> Result<(), Box<Error>> {
16    let mut window = Window::new(gust::WIDTH, gust::HEIGHT, "Hello");
17
18    let texture = Rc::new(Texture::from_path("examples/texture/Dirt.png").unwrap());
19    let mut batch = SpriteBatch::from(&texture);
20    for i in 0..1_000_000 {
21        let mut data = SpriteData::new(Vector::new(i as f32 * 1.0, i as f32 * 10.0));
22        data.set_texture_raw([Vector::new(0.0, 0.0), Vector::new(1.0, 1.0)]);
23        batch.push_sprite(data);
24    }
25
26    let event_handler = EventHandler::new(&window);
27
28    window.set_clear_color(Color::new(0.45, 0.0, 1.0));
29    window.enable_cursor();
30    window.poll(None);
31    while window.is_open() {
32        window.poll_events();
33        for event in event_handler.fetch() {
34            event_process(event, &mut window, &mut batch);
35        }
36        window.clear();
37        window.draw_mut(&mut batch);
38        window.display();
39    }
40
41    Ok(())
42}
examples/multi_window.rs (line 22)
9fn window1() -> Result<(), Box<Error>> {
10    let mut window = Window::new(600, 600, "Hello1");
11    let tex_leave = Rc::new(Texture::from_path("examples/texture/Z.png").unwrap());
12    let tex_dirt = Rc::new(Texture::from_path("examples/texture/Dirt.png").unwrap());
13    let mut sprite = Sprite::from(&tex_dirt);
14    let mut leave = Sprite::from(&tex_leave);
15    leave.set_position(Point::new(500.0, 500.0));
16    sprite.set_position(Point::new(10.0, 10.0));
17    leave.set_scale(Vector::new(0.5, 0.5));
18    leave.set_origin_to_center()?;
19
20    let event_handler = EventHandler::new(&window);
21
22    window.set_clear_color(Color::new(0.45, 0.0, 1.0));
23    window.enable_cursor();
24    window.poll(None);
25
26    while window.is_open() {
27        window.poll_events();
28        leave.rotate(1.0);
29        leave.update();
30        sprite.update();
31
32        for event in event_handler.fetch() {
33            event_process(event, &mut window);
34        }
35
36        window.clear();
37        window.draw(&mut sprite);
38        window.draw(&mut leave);
39        window.display();
40    }
41    Ok(())
42}
43
44fn window2() -> Result<(), Box<Error>> {
45    let mut window = Window::new(500, 500, "Hello2");
46    let font = Rc::new(RefCell::new(
47        Font::from_path("examples/font/terminus.ttf").unwrap(),
48    ));
49    let mut text = Text::from_str(&font, "I've been looking forward to this.");
50    text.set_position(Vector::new(5.0, 40.0));
51    let event_handler = EventHandler::new(&window);
52
53    window.set_clear_color(Color::new(1.0, 0.0, 1.0));
54    window.enable_cursor();
55    window.poll(None);
56
57    while window.is_open() {
58        text.update();
59        window.poll_events();
60
61        for event in event_handler.fetch() {
62            event_process(event, &mut window);
63        }
64
65        window.clear();
66        window.draw(&mut text);
67        window.display();
68    }
69    Ok(())
70}
examples/basic.rs (line 22)
8fn main() -> Result<(), Box<Error>> {
9    let mut window = Window::new(gust::WIDTH, gust::HEIGHT, "Hello");
10
11    let tex_leave = Rc::new(Texture::from_path("examples/texture/Z.png").unwrap());
12    let tex_dirt = Rc::new(Texture::from_path("examples/texture/Dirt.png").unwrap());
13    let mut sprite = Sprite::from(&tex_dirt);
14    let mut leave = Sprite::from(&tex_leave);
15    leave.set_position(Point::new(500.0, 500.0));
16    sprite.set_position(Point::new(10.0, 10.0));
17    leave.set_scale(Vector::new(0.5, 0.5));
18    leave.set_origin_to_center()?;
19
20    let event_handler = EventHandler::new(&window);
21
22    window.set_clear_color(Color::new(0.45, 0.0, 1.0));
23    window.enable_cursor();
24    window.poll(None);
25
26    while window.is_open() {
27        window.poll_events();
28        leave.rotate(1.0);
29        leave.update();
30        sprite.update();
31
32        for event in event_handler.fetch() {
33            event_process(event, &mut window);
34        }
35
36        window.clear();
37        window.draw(&sprite);
38        window.draw(&leave);
39        window.display();
40    }
41
42    Ok(())
43}
examples/view.rs (line 16)
7fn main() {
8    let mut window = Window::new(gust::WIDTH, gust::HEIGHT, "Hello");
9    let tex_leave = Rc::new(Texture::from_path("examples/texture/Z.png").unwrap());
10    let tex_dirt = Rc::new(Texture::from_path("examples/texture/Dirt.png").unwrap());
11    let event_handler = EventHandler::new(&window);
12    let mut sprite = Sprite::from(&tex_dirt);
13    let mut leave = Sprite::from(&tex_leave);
14
15    leave.set_position(Point::new(300.0, 300.0));
16    window.set_clear_color(Color::new(0.0, 0.0, 1.0));
17    window.enable_cursor();
18    window.poll(None);
19    leave.set_scale(Vector::new(0.5, 0.5));
20    leave
21        .set_origin_to_center()
22        .unwrap_or_else(|e| println!("{}", e));
23    while window.is_open() {
24        window.poll_events();
25        leave.rotate(1.0);
26        leave.update();
27        sprite.update();
28        window.view_mut().update();
29
30        for event in event_handler.fetch() {
31            event_process(event, &mut window);
32        }
33
34        window.clear();
35        window.draw(&mut sprite);
36        window.draw(&mut leave);
37        window.display();
38    }
39}
examples/font.rs (line 31)
8fn main() {
9    // Create drawer window
10    let mut window = Window::new(gust::WIDTH, gust::HEIGHT, "Hello");
11
12    // Create event handler
13    let event_handler = EventHandler::new(&window);
14
15    // Create font
16    let font = Rc::new(RefCell::new(
17        Font::from_path("examples/font/test.ttf").unwrap(),
18    ));
19
20    // Create text with font
21    let mut text = Text::new(&font);
22    text.set_content("Welcome to Gust you can write text and\na lot more !\t(Like tabs)");
23    text.set_position(Vector::new(100.0, 100.0));
24
25    // Create a 2nd text with font
26    let mut text2 = Text::from_str(&font, "Salut !");
27    text2.set_position(Vector::new(200.0, 200.0));
28    text2.update();
29
30    // Loop preparation
31    window.set_clear_color(Color::new(0.0, 0.0, 0.0));
32    window.enable_cursor();
33    window.poll(None);
34    while window.is_open() {
35        // update text
36        text.update();
37
38        // Poll event
39        window.poll_events();
40        event_handler
41            .fetch()
42            .for_each(|event| handle(&event, &mut window, &mut text));
43
44        // Draw process (Clear -> Draw -> Display)
45        window.clear();
46        window.draw(&text);
47        window.draw(&text2);
48        window.display();
49    }
50}
Source

pub fn white() -> Color

Source

pub fn red() -> Color

Examples found in repository?
examples/threads.rs (line 49)
39fn render(shared: &mut SharedWindow, recv: mpsc::Receiver<()>) {
40    shared.active();
41    let texture_rc =
42        Rc::new(Texture::from_path("examples/texture/Dirt.png").expect("Cannot open New.png"));
43    let sprite = Sprite::from(&texture_rc);
44
45    loop {
46        if recv.try_recv() == Ok(()) {
47            break;
48        }
49        shared.clear(Color::red());
50        shared.draw(&sprite);
51        shared.display();
52    }
53}
More examples
Hide additional examples
examples/shape.rs (line 79)
8fn main() {
9    let mut window = Window::new(gust::WIDTH, gust::HEIGHT, "Hello");
10    let vert_arr = VertexArray::from(
11        vec![
12            Vertex::new(
13                Vector::new(800.0, 400.0),
14                Vector::new(200.0, 0.0),
15                Color::new(0.0, 1.0, 0.0),
16            ),
17            Vertex::new(
18                Vector::new(1200.0, 700.0),
19                Vector::new(20.0, 10.0),
20                Color::new(0.0, 1.0, 1.0),
21            ),
22            Vertex::new(
23                Vector::new(1000.0, 300.0),
24                Vector::new(0.0, 0.0),
25                Color::new(0.0, 0.2, 1.0),
26            ),
27            Vertex::new(
28                Vector::new(800.0, 100.0),
29                Vector::new(0.0, 0.0),
30                Color::new(1.0, 1.0, 0.5),
31            ),
32            Vertex::new(
33                Vector::new(600.0, 300.0),
34                Vector::new(0.0, 0.0),
35                Color::new(0.5, 0.2, 0.1),
36            ),
37            Vertex::new(
38                Vector::new(400.0, 700.0),
39                Vector::new(0.0, 0.0),
40                Color::new(1.0, 0.0, 0.0),
41            ),
42        ]
43        .as_slice(),
44    );
45
46    let vert_arr_2 = VertexArray::from(
47        vec![
48            Vertex::new(Vector::new(0.0, 0.0), Vector::new(0.0, 0.0), Color::blue()),
49            Vertex::new(
50                Vector::new(0.0, 100.0),
51                Vector::new(0.0, 0.0),
52                Color::blue(),
53            ),
54            Vertex::new(
55                Vector::new(100.0, 100.0),
56                Vector::new(0.0, 0.0),
57                Color::blue(),
58            ),
59            Vertex::new(Vector::new(0.0, 0.0), Vector::new(0.0, 0.0), Color::green()),
60            Vertex::new(
61                Vector::new(100.0, 100.0),
62                Vector::new(0.0, 0.0),
63                Color::green(),
64            ),
65            Vertex::new(
66                Vector::new(100.0, 0.0),
67                Vector::new(0.0, 0.0),
68                Color::green(),
69            ),
70        ]
71        .as_slice(),
72    );
73
74    let vert_buf = VertexBuffer::new(Primitive::TriangleFan, vert_arr);
75    let vert_buf2 = VertexBuffer::new(Primitive::Triangles, vert_arr_2);
76
77    let event_handler = EventHandler::new(&window);
78
79    window.set_clear_color(Color::red());
80    window.poll(EventType::Key);
81    while window.is_open() {
82        window.poll_events();
83
84        for event in event_handler.fetch() {
85            match event.1 {
86                Events::Key(Key::Escape, _, Action::Press, _) => {
87                    window.close();
88                }
89                _ => {}
90            }
91        }
92
93        window.clear();
94        window.draw(&vert_buf);
95        window.draw(&vert_buf2);
96        window.display();
97    }
98}
Source

pub fn green() -> Color

Examples found in repository?
examples/shape.rs (line 59)
8fn main() {
9    let mut window = Window::new(gust::WIDTH, gust::HEIGHT, "Hello");
10    let vert_arr = VertexArray::from(
11        vec![
12            Vertex::new(
13                Vector::new(800.0, 400.0),
14                Vector::new(200.0, 0.0),
15                Color::new(0.0, 1.0, 0.0),
16            ),
17            Vertex::new(
18                Vector::new(1200.0, 700.0),
19                Vector::new(20.0, 10.0),
20                Color::new(0.0, 1.0, 1.0),
21            ),
22            Vertex::new(
23                Vector::new(1000.0, 300.0),
24                Vector::new(0.0, 0.0),
25                Color::new(0.0, 0.2, 1.0),
26            ),
27            Vertex::new(
28                Vector::new(800.0, 100.0),
29                Vector::new(0.0, 0.0),
30                Color::new(1.0, 1.0, 0.5),
31            ),
32            Vertex::new(
33                Vector::new(600.0, 300.0),
34                Vector::new(0.0, 0.0),
35                Color::new(0.5, 0.2, 0.1),
36            ),
37            Vertex::new(
38                Vector::new(400.0, 700.0),
39                Vector::new(0.0, 0.0),
40                Color::new(1.0, 0.0, 0.0),
41            ),
42        ]
43        .as_slice(),
44    );
45
46    let vert_arr_2 = VertexArray::from(
47        vec![
48            Vertex::new(Vector::new(0.0, 0.0), Vector::new(0.0, 0.0), Color::blue()),
49            Vertex::new(
50                Vector::new(0.0, 100.0),
51                Vector::new(0.0, 0.0),
52                Color::blue(),
53            ),
54            Vertex::new(
55                Vector::new(100.0, 100.0),
56                Vector::new(0.0, 0.0),
57                Color::blue(),
58            ),
59            Vertex::new(Vector::new(0.0, 0.0), Vector::new(0.0, 0.0), Color::green()),
60            Vertex::new(
61                Vector::new(100.0, 100.0),
62                Vector::new(0.0, 0.0),
63                Color::green(),
64            ),
65            Vertex::new(
66                Vector::new(100.0, 0.0),
67                Vector::new(0.0, 0.0),
68                Color::green(),
69            ),
70        ]
71        .as_slice(),
72    );
73
74    let vert_buf = VertexBuffer::new(Primitive::TriangleFan, vert_arr);
75    let vert_buf2 = VertexBuffer::new(Primitive::Triangles, vert_arr_2);
76
77    let event_handler = EventHandler::new(&window);
78
79    window.set_clear_color(Color::red());
80    window.poll(EventType::Key);
81    while window.is_open() {
82        window.poll_events();
83
84        for event in event_handler.fetch() {
85            match event.1 {
86                Events::Key(Key::Escape, _, Action::Press, _) => {
87                    window.close();
88                }
89                _ => {}
90            }
91        }
92
93        window.clear();
94        window.draw(&vert_buf);
95        window.draw(&vert_buf2);
96        window.display();
97    }
98}
Source

pub fn blue() -> Color

Examples found in repository?
examples/event.rs (line 83)
48fn event_process(event: Event, window: &mut Window, sprites: &mut HashMap<&'static str, Sprite>) {
49    match event.1 {
50        pressed!(Escape) => window.close(),
51        pressed!(Space) => {
52            sprites.get_mut("dirt_1").unwrap().rotate(45.0);
53        }
54        pressed!(W) => {
55            sprites
56                .get_mut("dirt_2")
57                .unwrap()
58                .translate(Vector::new(0.0, -10.0));
59        }
60        pressed!(A) => {
61            sprites
62                .get_mut("dirt_2")
63                .unwrap()
64                .translate(Vector::new(-10.0, 0.0));
65        }
66        pressed!(S) => {
67            sprites
68                .get_mut("dirt_2")
69                .unwrap()
70                .translate(Vector::new(0.0, 10.0));
71        }
72        pressed!(D) => {
73            sprites
74                .get_mut("dirt_2")
75                .unwrap()
76                .translate(Vector::new(10.0, 0.0));
77        }
78        Events::MouseButton(glfw::MouseButtonLeft, Action::Press, _) => {
79            let mouse_pos = window.mouse_pos();
80
81            if let Some(sprite) = sprites.get_mut("dirt_1") {
82                if sprite.contain(mouse_pos) {
83                    sprite.set_color(&Color::blue());
84                }
85            }
86        }
87        _ => {}
88    }
89}
More examples
Hide additional examples
examples/shape.rs (line 48)
8fn main() {
9    let mut window = Window::new(gust::WIDTH, gust::HEIGHT, "Hello");
10    let vert_arr = VertexArray::from(
11        vec![
12            Vertex::new(
13                Vector::new(800.0, 400.0),
14                Vector::new(200.0, 0.0),
15                Color::new(0.0, 1.0, 0.0),
16            ),
17            Vertex::new(
18                Vector::new(1200.0, 700.0),
19                Vector::new(20.0, 10.0),
20                Color::new(0.0, 1.0, 1.0),
21            ),
22            Vertex::new(
23                Vector::new(1000.0, 300.0),
24                Vector::new(0.0, 0.0),
25                Color::new(0.0, 0.2, 1.0),
26            ),
27            Vertex::new(
28                Vector::new(800.0, 100.0),
29                Vector::new(0.0, 0.0),
30                Color::new(1.0, 1.0, 0.5),
31            ),
32            Vertex::new(
33                Vector::new(600.0, 300.0),
34                Vector::new(0.0, 0.0),
35                Color::new(0.5, 0.2, 0.1),
36            ),
37            Vertex::new(
38                Vector::new(400.0, 700.0),
39                Vector::new(0.0, 0.0),
40                Color::new(1.0, 0.0, 0.0),
41            ),
42        ]
43        .as_slice(),
44    );
45
46    let vert_arr_2 = VertexArray::from(
47        vec![
48            Vertex::new(Vector::new(0.0, 0.0), Vector::new(0.0, 0.0), Color::blue()),
49            Vertex::new(
50                Vector::new(0.0, 100.0),
51                Vector::new(0.0, 0.0),
52                Color::blue(),
53            ),
54            Vertex::new(
55                Vector::new(100.0, 100.0),
56                Vector::new(0.0, 0.0),
57                Color::blue(),
58            ),
59            Vertex::new(Vector::new(0.0, 0.0), Vector::new(0.0, 0.0), Color::green()),
60            Vertex::new(
61                Vector::new(100.0, 100.0),
62                Vector::new(0.0, 0.0),
63                Color::green(),
64            ),
65            Vertex::new(
66                Vector::new(100.0, 0.0),
67                Vector::new(0.0, 0.0),
68                Color::green(),
69            ),
70        ]
71        .as_slice(),
72    );
73
74    let vert_buf = VertexBuffer::new(Primitive::TriangleFan, vert_arr);
75    let vert_buf2 = VertexBuffer::new(Primitive::Triangles, vert_arr_2);
76
77    let event_handler = EventHandler::new(&window);
78
79    window.set_clear_color(Color::red());
80    window.poll(EventType::Key);
81    while window.is_open() {
82        window.poll_events();
83
84        for event in event_handler.fetch() {
85            match event.1 {
86                Events::Key(Key::Escape, _, Action::Press, _) => {
87                    window.close();
88                }
89                _ => {}
90            }
91        }
92
93        window.clear();
94        window.draw(&vert_buf);
95        window.draw(&vert_buf2);
96        window.display();
97    }
98}
Source

pub fn black() -> Color

Trait Implementations§

Source§

impl Add for Color

Source§

type Output = Color

The resulting type after applying the + operator.
Source§

fn add(self, other: Color) -> Color

Performs the + operation. Read more
Source§

impl Clone for Color

Source§

fn clone(&self) -> Color

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Color

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Color

Source§

fn default() -> Color

Returns the “default value” for a type. Read more
Source§

impl Into<[u8; 4]> for Color

Source§

fn into(self) -> [u8; 4]

Converts this type into the (usually inferred) input type.
Source§

impl Into<(u8, u8, u8, u8)> for Color

Source§

fn into(self) -> (u8, u8, u8, u8)

Converts this type into the (usually inferred) input type.
Source§

impl Mul for Color

Source§

type Output = Color

The resulting type after applying the * operator.
Source§

fn mul(self, other: Color) -> Color

Performs the * operation. Read more
Source§

impl PartialEq for Color

Source§

fn eq(&self, other: &Color) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Sub for Color

Source§

type Output = Color

The resulting type after applying the - operator.
Source§

fn sub(self, other: Color) -> Color

Performs the - operation. Read more
Source§

impl Copy for Color

Source§

impl StructuralPartialEq for Color

Auto Trait Implementations§

§

impl Freeze for Color

§

impl RefUnwindSafe for Color

§

impl Send for Color

§

impl Sync for Color

§

impl Unpin for Color

§

impl UnsafeUnpin for Color

§

impl UnwindSafe for Color

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: Copy + PartialEq + Debug + Any,

Source§

fn is<T>() -> bool
where T: Scalar,

Tests if Self the same as the type T Read more
Source§

impl<T> SetParameter for T

Source§

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result
where T: Parameter<Self>,

Sets value as a parameter of self.
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.