add some docs
This commit is contained in:
parent
674c9cc4d3
commit
dc579bf4a2
1 changed files with 4 additions and 0 deletions
|
@ -17,6 +17,8 @@ use std::str::FromStr;
|
||||||
pub struct Day(u8);
|
pub struct Day(u8);
|
||||||
|
|
||||||
impl Day {
|
impl Day {
|
||||||
|
/// Creates a [`Day`] from the provided value if it's in the valid range,
|
||||||
|
/// returns [`None`] otherwise.
|
||||||
pub fn new(day: u8) -> Option<Self> {
|
pub fn new(day: u8) -> Option<Self> {
|
||||||
if day == 0 || day > 25 {
|
if day == 0 || day > 25 {
|
||||||
return None;
|
return None;
|
||||||
|
@ -29,6 +31,7 @@ impl Day {
|
||||||
Self(day)
|
Self(day)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Converts the [`Day`] into an [`u8`].
|
||||||
pub fn into_inner(self) -> u8 {
|
pub fn into_inner(self) -> u8 {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
@ -63,6 +66,7 @@ impl FromStr for Day {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An error which can be returned when parsing a [`Day`].
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DayFromStrError;
|
pub struct DayFromStrError;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue