Struct Border

Source
pub struct Border {
    pub border: String,
    pub h: u16,
    pub w: u16,
    pub x: u16,
    pub y: u16,
}
Expand description

A structure representing a border with specific dimensions and position.

Fields§

§border: String

The character or string used for the border.

§h: u16

The height of the area defined by the border.

§w: u16

The width of the area defined by the border.

§x: u16

The x-coordinate position of the border’s top-left corner.

§y: u16

The y-coordinate position of the border’s top-left corner.

Implementations§

Source§

impl Border

Source

pub fn new(h: u16, w: u16, x: u16, y: u16, border: String) -> Border

Creates a new instance of Border.

§Parameters
  • h: The height of the border area.
  • w: The width of the border area.
  • x: The x-coordinate of the border’s position.
  • y: The y-coordinate of the border’s position.
  • border: A string representing the border character(s).
§Returns

Returns a new Border instance.

Source

pub fn draw(&self)

Draws the border on the console.

This method will print the border to the console starting at the specified (x, y) position. The border consists of repeated characters specified in the border field, and it is drawn for the height and width defined in the struct.

§Example
let border = Border::new(5, 10, 2, 1, "*".to_string());
border.draw();

This will create a border 10 characters wide and 5 characters high, starting from the x-coordinate 2 and y-coordinate 1.

Auto Trait Implementations§

§

impl Freeze for Border

§

impl RefUnwindSafe for Border

§

impl Send for Border

§

impl Sync for Border

§

impl Unpin for Border

§

impl UnwindSafe for Border

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.