Skip to main content

rust_toolchain/channel/
nightly.rs

1use crate::Date;
2
3/// The `Nightly` release [`channel`]
4///
5/// [`channel`]: https://rust-lang.github.io/rustup/concepts/channels.html
6#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
7pub struct Nightly {
8    /// A short YYYY-MM-DD associated date
9    pub date: Date,
10}
11
12impl Nightly {
13    /// Instantiate a new `Nightly` struct, representing the version of a release channel.
14    pub fn new(year: u16, month: u8, day: u8) -> Self {
15        Self {
16            date: Date::new(year, month, day),
17        }
18    }
19}
20
21#[cfg(test)]
22mod tests {
23    use crate::{Date, channel::Nightly};
24
25    #[yare::parameterized(
26        patch1 = { Date::new(0, 0, 0), Date::new(0, 0, 1) },
27        minor1 = { Date::new(0, 0, 0), Date::new(0, 1, 0) },
28        major1 = { Date::new(0, 0, 0), Date::new(1, 0, 0) },
29        minor_over_patch = { Date::new(0, 0, 99), Date::new(0, 1, 0) },
30        major_over_patch = { Date::new(0, 0, 99), Date::new(1, 0, 0) },
31        major_over_minor = { Date::new(0, 99, 0), Date::new(1, 0, 0) },
32    )]
33    fn ord(left: Date, right: Date) {
34        let left = Nightly { date: left };
35        let right = Nightly { date: right };
36
37        assert!(left < right);
38    }
39}