feature_set/
feature.rs

1use crate::Since;
2
3/// A named, versioned feature that can be provided or required.
4///
5/// A `Feature` is uniquely identified by its name and version.
6/// A `Feature` tracks the date it was introduced and the version of the crate it was introduced in.
7#[derive(Debug, Clone)]
8pub struct Feature {
9    pub(crate) name: &'static str,
10    pub(crate) ver: u64,
11    pub(crate) since: Since,
12}
13
14impl Feature {
15    pub const fn new(
16        name_ver: (&'static str, u64),
17        since_date: &'static str,
18        since_ver: (u64, u64, u64),
19    ) -> Self {
20        Self {
21            name: name_ver.0,
22            ver: name_ver.1,
23            since: Since::new(since_date, since_ver),
24        }
25    }
26
27    pub fn name(&self) -> &'static str {
28        self.name
29    }
30
31    pub fn ver(&self) -> u64 {
32        self.ver
33    }
34
35    pub fn since(&self) -> &Since {
36        &self.since
37    }
38}