Skip to content

Commit 97586e7

Browse files
committed
Split the rust-release package into modules
1 parent 63fd6e2 commit 97586e7

File tree

3 files changed

+71
-47
lines changed

3 files changed

+71
-47
lines changed

crates/rust-release/src/lib.rs

Lines changed: 15 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,20 @@
1616
#![deny(unsafe_code)]
1717
#![deny(missing_docs)]
1818

19+
use crate::toolchain::ReleaseToolchain;
20+
21+
/// Describes toolchains in so far they're relevant to a release
22+
pub mod toolchain;
23+
24+
/// Describes the version of a release
25+
pub mod version;
26+
1927
/// Type to model a Rust release.
2028
#[derive(Clone, Debug, Eq, PartialEq)]
2129
pub struct RustRelease {
2230
version: ReleaseVersion,
2331
release_date: Option<rust_toolchain::Date>,
24-
toolchains: Vec<ExtendedToolchain>,
32+
toolchains: Vec<ReleaseToolchain>,
2533
}
2634

2735
impl RustRelease {
@@ -30,7 +38,7 @@ impl RustRelease {
3038
pub fn new(
3139
version: ReleaseVersion,
3240
release_date: Option<rust_toolchain::Date>,
33-
toolchains: impl IntoIterator<Item = ExtendedToolchain>,
41+
toolchains: impl IntoIterator<Item = ReleaseToolchain>,
3442
) -> Self {
3543
Self {
3644
version,
@@ -50,7 +58,7 @@ impl RustRelease {
5058
}
5159

5260
/// Toolchains associated with the release
53-
pub fn toolchains(&self) -> impl Iterator<Item = &ExtendedToolchain> {
61+
pub fn toolchains(&self) -> impl Iterator<Item = &ReleaseToolchain> {
5462
self.toolchains.iter()
5563
}
5664
}
@@ -69,46 +77,6 @@ pub enum ReleaseVersion {
6977
Nightly(rust_toolchain::channel::Nightly),
7078
}
7179

72-
/// Type to model a Rust toolchain, with additional metadata relevant to a
73-
/// release.
74-
#[derive(Clone, Debug, Eq, PartialEq)]
75-
pub struct ExtendedToolchain {
76-
toolchain: rust_toolchain::Toolchain,
77-
tier: TargetTier,
78-
}
79-
80-
impl ExtendedToolchain {
81-
/// Create an ExtendedToolchain from a rust_toolchain::Toolchain
82-
pub fn new(toolchain: rust_toolchain::Toolchain, tier: TargetTier) -> Self {
83-
Self { toolchain, tier }
84-
}
85-
86-
/// Get the toolchain
87-
pub fn toolchain(&self) -> &rust_toolchain::Toolchain {
88-
&self.toolchain
89-
}
90-
91-
/// Get the toolchain tier
92-
pub fn tier(&self) -> TargetTier {
93-
self.tier
94-
}
95-
}
96-
97-
/// Support tier for a target
98-
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
99-
pub enum TargetTier {
100-
/// Tier 1 target
101-
T1,
102-
/// Tier 2 target
103-
T2,
104-
/// Tier 2.5 target
105-
T2_5,
106-
/// Tier 3 target
107-
T3,
108-
/// Tier is unknown
109-
Unknown,
110-
}
111-
11280
#[cfg(test)]
11381
mod tests {
11482
use super::*;
@@ -124,15 +92,15 @@ mod tests {
12492
let release = RustRelease::new(
12593
version,
12694
None,
127-
vec![ExtendedToolchain::new(
95+
vec![ReleaseToolchain::new(
12896
rust_toolchain::Toolchain::new(
12997
rust_toolchain::Channel::Stable(stable_version.clone()),
13098
None,
13199
rust_toolchain::Target::host(),
132100
HashSet::new(),
133101
HashSet::new(),
134102
),
135-
TargetTier::Unknown,
103+
toolchain::TargetTier::Unknown,
136104
)],
137105
);
138106

@@ -153,15 +121,15 @@ mod tests {
153121
let release = RustRelease::new(
154122
version,
155123
date.clone(),
156-
vec![ExtendedToolchain::new(
124+
vec![ReleaseToolchain::new(
157125
rust_toolchain::Toolchain::new(
158126
rust_toolchain::Channel::Stable(stable_version.clone()),
159127
date,
160128
rust_toolchain::Target::host(),
161129
HashSet::new(),
162130
HashSet::new(),
163131
),
164-
TargetTier::Unknown,
132+
toolchain::TargetTier::Unknown,
165133
)],
166134
);
167135

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//! Types for working with Rust toolchains in so far they're relevant to a Rust release.
2+
3+
/// Type to model a Rust toolchain, with additional metadata relevant to a
4+
/// release.
5+
#[derive(Clone, Debug, Eq, PartialEq)]
6+
pub struct ReleaseToolchain {
7+
toolchain: rust_toolchain::Toolchain,
8+
tier: TargetTier,
9+
}
10+
11+
impl ReleaseToolchain {
12+
/// Create an ExtendedToolchain from a rust_toolchain::Toolchain
13+
pub fn new(toolchain: rust_toolchain::Toolchain, tier: TargetTier) -> Self {
14+
Self { toolchain, tier }
15+
}
16+
17+
/// Get the toolchain
18+
pub fn toolchain(&self) -> &rust_toolchain::Toolchain {
19+
&self.toolchain
20+
}
21+
22+
/// Get the toolchain tier
23+
pub fn tier(&self) -> TargetTier {
24+
self.tier
25+
}
26+
}
27+
28+
/// Support tier for a target
29+
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
30+
pub enum TargetTier {
31+
/// Tier 1 target
32+
T1,
33+
/// Tier 2 target
34+
T2,
35+
/// Tier 2.5 target
36+
T2_5,
37+
/// Tier 3 target
38+
T3,
39+
/// Tier is unknown
40+
Unknown,
41+
}

crates/rust-release/src/version.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//! Version information for a Rust release.
2+
3+
/// A combination of a channel and the version number.
4+
///
5+
/// For stable and beta releases, we have a three component MAJOR.MINOR.PATCH
6+
/// version number. For nightly releases, we have a release date.
7+
#[derive(Clone, Debug, Eq, PartialEq)]
8+
pub enum ReleaseVersion {
9+
/// A stable channel release version
10+
Stable(rust_toolchain::channel::Stable),
11+
/// A beta channel release version
12+
Beta(rust_toolchain::channel::Beta),
13+
/// A nightly channel release version
14+
Nightly(rust_toolchain::channel::Nightly),
15+
}

0 commit comments

Comments
 (0)