Struct bulls_and_cows::Host

source ·
pub struct Host<T: Eq + Hash + Clone> { /* private fields */ }
Expand description

The game host for generating the question and answering for the question.

Implementations§

source§

impl<T: Eq + Hash + Clone> Host<T>

source

pub fn get_letters(&self) -> &HashSet<T>

source

pub fn get_answer_length(&self) -> usize

source

pub fn get_answer(&self) -> &[T]

source§

impl<T: Eq + Hash + Clone> Host<T>

source

pub fn build( letters: HashSet<T>, answer_length: usize ) -> Result<Host<T>, HostError<T>>

Build a bulls-and-cows game host with a fixed answer.

source

pub fn build_with_random_answer( letters: HashSet<T>, answer_length: usize ) -> Result<Host<T>, HostError<T>>

Build a bulls-and-cows game host with a random answer.

source

pub fn build_with_known_answer( letters: HashSet<T>, answer: Vec<T> ) -> Result<Host<T>, HostError<T>>

Build a bulls-and-cows game host with a known answer.

source

pub unsafe fn build_with_known_answer_unsafe( letters: HashSet<T>, answer: Vec<T> ) -> Host<T>

Build a bulls-and-cows game host with a known answer unsafely.

source

pub fn renew_with_random_answer( &mut self, answer_length: usize ) -> Result<(), HostError<T>>

Renew this host with a random answer.

source

pub fn renew_with_known_answer( &mut self, answer: Vec<T> ) -> Result<(), HostError<T>>

Renew this host with a known answer.

source

pub unsafe fn renew_with_known_answer_unsafe(&mut self, answer: Vec<T>)

Renew this host with a known answer unsafely.

source§

impl<T: Eq + Hash + Clone> Host<T>

source

pub fn answer(&self, answer: &[T]) -> Result<(usize, usize), HostError<T>>

Answer for the question. If the format of the input answer is correct, it returns the number of bulls and the number of cows.

Trait Implementations§

source§

impl<T: Debug + Eq + Hash + Clone> Debug for Host<T>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Host<T>where T: RefUnwindSafe,

§

impl<T> Send for Host<T>where T: Send,

§

impl<T> Sync for Host<T>where T: Sync,

§

impl<T> Unpin for Host<T>where T: Unpin,

§

impl<T> UnwindSafe for Host<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V