pub struct Answers { /* private fields */ }Expand description
Stores correct and incorrect answers for a puzzle, along with hints such as “too large” and “too small”.
Implementations§
Source§impl Answers
impl Answers
pub fn correct_answer_ref(&self) -> &Option<Answer>
pub fn wrong_answers_ref(&self) -> &Vec<Answer>
pub fn low_bounds_ref(&self) -> &Option<i128>
pub fn high_bounds_ref(&self) -> &Option<i128>
Sourcepub fn check(&self, answer: &Answer) -> Option<CheckResult>
pub fn check(&self, answer: &Answer) -> Option<CheckResult>
Checks if this answer is correct or incorrect according to the information
stored in this Answers database.
None is returned when the supplied answer does not match any known
incorrect values, and the database does not have a known correct value.
When a None value is returned, the caller should submit the answer as
a solution to the puzzle using the Advent of Code client. The caller
should then update this object with the response depending on if the
client say it was correct or incorrect.
Sourcepub fn add_wrong_answer(&mut self, answer: Answer)
pub fn add_wrong_answer(&mut self, answer: Answer)
Adds an answer to the list of known wrong answers.
Sourcepub fn set_correct_answer(&mut self, answer: Answer)
pub fn set_correct_answer(&mut self, answer: Answer)
Sets this answer as the known correct answer.
Sourcepub fn set_low_bounds(&mut self, answer: Answer) -> i128
pub fn set_low_bounds(&mut self, answer: Answer) -> i128
Sets a low boundary value in the cache.
If the cache has an existing low boundary then the highest value will be used as the new high boundary.
Any numeric answer passed to Answers::check will be returned as
CheckResult::TooLow if it equals or is smaller than the low boundary.
Sourcepub fn set_high_bounds(&mut self, answer: Answer) -> i128
pub fn set_high_bounds(&mut self, answer: Answer) -> i128
Sets a high boundary value in the cache.
If the cache has an existing high boundary then the lowest value will be used as the new high boundary.
Any numeric answer passed to Answers::check will be returned as
CheckResult::TooHigh if it equals or is larger than the high boundary.