pub struct Date<'a> {
pub year: Cow<'a, str>,
pub month: Cow<'a, str>,
pub day: Cow<'a, str>,
}
Expand description
Represents a date value.
Fields§
§year: Cow<'a, str>
Represents the year of a date. Must be 4 decimal digits greater than 0“.
month: Cow<'a, str>
Represents the month of a date. Must be 2 decimal digits greater than 0 less than 13.
day: Cow<'a, str>
Represents the day of a date. Must be 2 decimal digits greater than 0less than 28, 29, 30, or 31 depending on the month and whether the year is a leap year.
Implementations§
Source§impl<'a> Date<'a>
impl<'a> Date<'a>
Sourcepub fn from_str<S>(year: S, month: S, day: S) -> Result<Date<'a>, TOMLError>
pub fn from_str<S>(year: S, month: S, day: S) -> Result<Date<'a>, TOMLError>
Create a new Date
from string type values. Returns Ok()
on success and Err()
on failure.
§Examples
use tomllib::types::Date;
let date = Date::from_str("1991", "09", "23").unwrap();
Sourcepub fn validate(&self) -> bool
pub fn validate(&self) -> bool
Validates a created Date
.
§Examples
use tomllib::types::Date;
let date_wrong = Date{year: "76563".into(), month: "10".into(), day: "20".into()};
let date_right = Date{year: "1763".into(), month: "10".into(), day: "20".into()};
assert!(!date_wrong.validate());
assert!(date_right.validate());
Trait Implementations§
impl<'a> Eq for Date<'a>
Auto Trait Implementations§
impl<'a> Freeze for Date<'a>
impl<'a> RefUnwindSafe for Date<'a>
impl<'a> Send for Date<'a>
impl<'a> Sync for Date<'a>
impl<'a> Unpin for Date<'a>
impl<'a> UnwindSafe for Date<'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