pub struct Fruit<'a> {
score: i32,
grow_snake: i16,
graphic_block: GraphicBlock<'a>,
}
Expand description
Represents a fruit on the map. Fruits have a score value and are displayed as graphical blocks.
Fields§
§score: i32
§grow_snake: i16
§graphic_block: GraphicBlock<'a>
Implementations§
Source§impl<'a> Fruit<'a>
impl<'a> Fruit<'a>
Sourcepub fn new(
score: i32,
grow_snake_by_relative_nb: i16,
position: Position,
image: &'a str,
) -> Fruit<'a>
pub fn new( score: i32, grow_snake_by_relative_nb: i16, position: Position, image: &'a str, ) -> Fruit<'a>
Creates a new Fruit
at a given position with an associated score and image.
Sourcepub fn is_at_position(&self, position: &Position) -> bool
pub fn is_at_position(&self, position: &Position) -> bool
Checks if the fruit is at a specific position.
Sourcepub fn set_position(&mut self, position: Position)
pub fn set_position(&mut self, position: Position)
Checks if the fruit is at a specific position.
pub fn get_grow_snake(&self) -> i16
Trait Implementations§
Source§impl WidgetRef for Fruit<'_>
Enables Fruit
to be rendered as a reference widget.
impl WidgetRef for Fruit<'_>
Enables Fruit
to be rendered as a reference widget.
Source§fn render_ref(&self, area: Rect, buf: &mut Buffer)
fn render_ref(&self, area: Rect, buf: &mut Buffer)
Draws the current state of the widget in the given buffer. That is the only method required
to implement a custom widget.
impl<'a> StructuralPartialEq for Fruit<'a>
Auto Trait Implementations§
impl<'a> Freeze for Fruit<'a>
impl<'a> RefUnwindSafe for Fruit<'a>
impl<'a> Send for Fruit<'a>
impl<'a> Sync for Fruit<'a>
impl<'a> Unpin for Fruit<'a>
impl<'a> UnwindSafe for Fruit<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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