Struct Label

Source
pub struct Label { /* private fields */ }
Expand description

A structure representing a text label that can be drawn on a console at a specific position.

Implementations§

Source§

impl Label

Source

pub fn new(text: &str, x: u16, y: u16) -> Self

Creates a new Label instance.

§Arguments
  • text - A string slice that holds the text of the label.
  • x - The horizontal position (x-coordinate) where the label will be drawn.
  • y - The vertical position (y-coordinate) where the label will be drawn.
§Returns

A new instance of Label.

Source

pub fn draw(&self, stdout: &mut impl Write) -> Result<()>

Draws the label at the specified (x, y) coordinates in the console.

§Arguments
  • stdout - A mutable reference to any type that implements the Write trait, allowing the method to write the label’s text to the specified output.
§Errors

Returns an io::Result<()>, which will contain an error if the write operation fails.

§Example
use std::io::{self, Write};
let mut stdout = io::stdout();
let label = Label::new("Hello, world!", 10, 5);
label.draw(&mut stdout).unwrap(); // Draws the label

Auto Trait Implementations§

§

impl Freeze for Label

§

impl RefUnwindSafe for Label

§

impl Send for Label

§

impl Sync for Label

§

impl Unpin for Label

§

impl UnwindSafe for Label

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.