Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core2: refactor playground II #222

Draft
wants to merge 4 commits into
base: core2
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions book/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
book
6 changes: 6 additions & 0 deletions book/book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[book]
authors = ["Martijn Gribnau <garm@ilumeo.com>"]
language = "en"
multilingual = false
src = "src"
title = "rust-releases"
20 changes: 20 additions & 0 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Summary

- [Introduction](./introduction.md)

# Concepts

- [rust-toolchain](./concepts_rust_toolchain.md)
- [rust-releases](./concepts_rust_releases.md)

# Sources

- [rust-changelog](./sources_rust_changelog.md)
- [rust-dist](./sources_rust_dist.md)
- [rust-dist-cli (deprecated)](./sources_rust_dist_cli.md)
- [rust-channel-manifests (deprecated)](./sources_rust_channel_manifests.md)
[//]: # (- Future: github-rust-releases)

# Developer Resources

- [Resources](./developer_resources.md)
1 change: 1 addition & 0 deletions book/src/concepts_rust_releases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# rust-releases
1 change: 1 addition & 0 deletions book/src/concepts_rust_toolchain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# rust-toolchain
26 changes: 26 additions & 0 deletions book/src/developer_resources.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Useful resources

## Forge

- [Forge Home](https://forge.rust-lang.org/)
- [Rust Release Channel Layout](https://forge.rust-lang.org/infra/channel-layout.html)
- [Rust "Other installation methods"](https://forge.rust-lang.org/infra/other-installation-methods.html)

## Rustup

- [on Channels](https://rust-lang.github.io/rustup/concepts/channels.html)
- [on Toolchains](https://rust-lang.github.io/rustup/concepts/toolchains.html)
- [on Components](https://rust-lang.github.io/rustup/concepts/components.html)
- [on Profiles](https://rust-lang.github.io/rustup/concepts/profiles.html)
- [Environment Variables](https://rust-lang.github.io/rustup/environment-variables.html)

## Rust on GitHub

- [RELEASES.md: Rust changelog](https://raw.githubusercontent.com/rust-lang/rust/master/RELEASES.md)
- [RFC 0131: target specification](https://github.com/rust-lang/rfcs/blob/master/text/0131-target-specification.md#detailed-design)

## Misc

- [Rust Platform Support](https://doc.rust-lang.org/rustc/platform-support.html)
- [Rustup Components History](https://rust-lang.github.io/rustup-components-history/index.html) by Nightly version and
target
10 changes: 10 additions & 0 deletions book/src/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Introduction

Welcome! This is a book intended to document the [rust-releases](https://github.com/foresterre/rust-releases/) project.
It's a bit empty right now. Check back in the future!

For additional documentation, you may find the following resources useful:

- [docs.rs/rust-releases](https://docs.rs/rust-releases/): library docs
- [github.com/foresterre/rust-releases](https://github.com/foresterre/rust-releases/): crate introduction and
documentation in the readme
1 change: 1 addition & 0 deletions book/src/sources_rust.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# rust-dist
1 change: 1 addition & 0 deletions book/src/sources_rust_changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# rust-changelog
1 change: 1 addition & 0 deletions book/src/sources_rust_channel_manifests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# rust-channel-manifests
1 change: 1 addition & 0 deletions book/src/sources_rust_dist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# rust-dist
1 change: 1 addition & 0 deletions book/src/sources_rust_dist_cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# rust-dist
3 changes: 3 additions & 0 deletions crates/core2/src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub use crate::distribution::Distribution;
pub use crate::register::Register;
pub use crate::set::DistributionSet;
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use std::cmp::Ordering;
/// 3. When comparing two releases of the same channel, `a` and `b`, and `date(a) * date(b)`, then `a * b`.
/// * Only `nightly` has a date, so if the version of two `stable` or `beta` releases match, they will be considered equal.
#[derive(Clone, Debug, Eq)]
pub struct CompareRelease(pub Distribution);
pub struct ComparableDistribution(pub Distribution);

impl PartialEq for CompareRelease {
impl PartialEq for ComparableDistribution {
fn eq(&self, other: &Self) -> bool {
let lhs = &self.0;
let rhs = &other.0;
Expand All @@ -30,13 +30,13 @@ impl PartialEq for CompareRelease {
}
}

impl PartialOrd for CompareRelease {
impl PartialOrd for ComparableDistribution {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(&other))
}
}

impl Ord for CompareRelease {
impl Ord for ComparableDistribution {
fn cmp(&self, other: &Self) -> Ordering {
// pre: `lhs` and `rhs` must be the same channel!
fn compare_same_channel(lhs: &Distribution, rhs: &Distribution) -> Ordering {
Expand All @@ -61,9 +61,9 @@ impl Ord for CompareRelease {

#[cfg(test)]
mod tests_compare_release {
use crate::set::compare::CompareRelease;
use crate::comparable_distribution::ComparableDistribution;
use crate::Distribution;
use rust_toolchain::{Channel, Platform, ReleaseDate, RustVersion};
use rust_toolchain::{Channel, ReleaseDate, RustVersion, Target};
use std::cmp::Ordering;
use yare::parameterized;

Expand All @@ -74,7 +74,7 @@ mod tests_compare_release {
date,
rust_toolchain::Toolchain::new(
Channel::stable(RustVersion::new(1, 2, 3)),
Platform::host(),
Target::host(),
),
)
}
Expand All @@ -90,8 +90,8 @@ mod tests_compare_release {
let mut release1 = default_test_subject();
release1.toolchain_mut().channel = channel;

let lhs = CompareRelease(release0);
let rhs = CompareRelease(release1);
let lhs = ComparableDistribution(release0);
let rhs = ComparableDistribution(release1);

assert_eq!(lhs, rhs);
assert_eq!(lhs.cmp(&rhs), Ordering::Equal);
Expand All @@ -104,8 +104,8 @@ mod tests_compare_release {
let mut release1 = default_test_subject();
release1.toolchain_mut().channel = Channel::stable(RustVersion::new(0, 0, 0));

let lhs = CompareRelease(release0);
let rhs = CompareRelease(release1);
let lhs = ComparableDistribution(release0);
let rhs = ComparableDistribution(release1);

// lhs != rhs
assert_ne!(lhs, rhs);
Expand All @@ -120,8 +120,8 @@ mod tests_compare_release {
let mut release1 = default_test_subject();
release1.toolchain_mut().channel = Channel::beta(RustVersion::new(0, 0, 0));

let stable = CompareRelease(release0);
let beta = CompareRelease(release1);
let stable = ComparableDistribution(release0);
let beta = ComparableDistribution(release1);

// lhs != rhs
assert_ne!(stable, beta);
Expand All @@ -136,8 +136,8 @@ mod tests_compare_release {
let mut release1 = default_test_subject();
release1.toolchain_mut().channel = Channel::nightly(ReleaseDate::new(0, 0, 0));

let stable = CompareRelease(release0);
let nightly = CompareRelease(release1);
let stable = ComparableDistribution(release0);
let nightly = ComparableDistribution(release1);

// lhs != rhs
assert_ne!(stable, nightly);
Expand All @@ -152,8 +152,8 @@ mod tests_compare_release {
let mut release1 = default_test_subject();
release1.toolchain_mut().channel = Channel::stable(RustVersion::new(0, 0, 0));

let lhs = CompareRelease(release0);
let rhs = CompareRelease(release1);
let lhs = ComparableDistribution(release0);
let rhs = ComparableDistribution(release1);

// lhs != rhs
assert_ne!(lhs, rhs);
Expand All @@ -168,8 +168,8 @@ mod tests_compare_release {
let mut release1 = default_test_subject();
release1.toolchain_mut().channel = Channel::stable(RustVersion::new(0, 0, 0));

let beta = CompareRelease(release0);
let stable = CompareRelease(release1);
let beta = ComparableDistribution(release0);
let stable = ComparableDistribution(release1);

// lhs != rhs
assert_ne!(beta, stable);
Expand All @@ -184,8 +184,8 @@ mod tests_compare_release {
let mut release1 = default_test_subject();
release1.toolchain_mut().channel = Channel::nightly(ReleaseDate::new(0, 0, 0));

let beta = CompareRelease(release0);
let nightly = CompareRelease(release1);
let beta = ComparableDistribution(release0);
let nightly = ComparableDistribution(release1);

// lhs != rhs
assert_ne!(beta, nightly);
Expand All @@ -200,8 +200,8 @@ mod tests_compare_release {
let mut release1 = default_test_subject();
release1.toolchain_mut().channel = Channel::nightly(ReleaseDate::new(0, 0, 0));

let lhs = CompareRelease(release0);
let rhs = CompareRelease(release1);
let lhs = ComparableDistribution(release0);
let rhs = ComparableDistribution(release1);

// lhs != rhs
assert_ne!(lhs, rhs);
Expand All @@ -216,8 +216,8 @@ mod tests_compare_release {
let mut release1 = default_test_subject();
release1.toolchain_mut().channel = Channel::stable(RustVersion::new(0, 0, 0));

let nightly = CompareRelease(release0);
let stable = CompareRelease(release1);
let nightly = ComparableDistribution(release0);
let stable = ComparableDistribution(release1);

// lhs != rhs
assert_ne!(nightly, stable);
Expand All @@ -232,8 +232,8 @@ mod tests_compare_release {
let mut release1 = default_test_subject();
release1.toolchain_mut().channel = Channel::beta(RustVersion::new(0, 0, 0));

let nightly = CompareRelease(release0);
let beta = CompareRelease(release1);
let nightly = ComparableDistribution(release0);
let beta = ComparableDistribution(release1);

// lhs != rhs
assert_ne!(nightly, beta);
Expand Down Expand Up @@ -269,7 +269,7 @@ impl Ord for CompareChannel<'_> {

#[cfg(test)]
mod tests_channel_comparator {
use crate::set::compare::CompareChannel;
use super::CompareChannel;
use rust_toolchain::{Channel, ReleaseDate, RustVersion};
use std::cmp::Ordering;
use yare::parameterized;
Expand Down
Loading
Loading