Skip to content

Commit

Permalink
Update to rust edition 2021!
Browse files Browse the repository at this point in the history
  • Loading branch information
hunger committed Oct 21, 2021
1 parent 51ce4f6 commit 67255a4
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 42 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[workspace]
members = ["crates/*", "commands/*"]
resolver = "2"
2 changes: 1 addition & 1 deletion commands/gng-build-agent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "gng-build-agent"
version = "0.1.0"
edition = "2018"
edition = "2021"
authors = ["Tobias Hunger <tobias.hunger@gmail.com>"]
license = "GPL-3.0-or-later"
categories = ["tool", "packaging", "distribution", "linux", "cleanroom"]
Expand Down
6 changes: 3 additions & 3 deletions commands/gng-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "gng-build"
version = "0.1.0"
edition = "2018"
edition = "2021"
authors = ["Tobias Hunger <tobias.hunger@gmail.com>"]
license = "GPL-3.0-or-later"
categories = ["tool", "packaging", "distribution", "linux", "cleanroom" ]
keywords = ["tool", "packaging", "distribution", "linux", "cleanroom" ]
categories = ["tool", "packaging", "distribution", "linux", "cleanroom"]
keywords = ["tool", "packaging", "distribution", "linux", "cleanroom"]
repository = "https://github.com/hunger/gng"

[dependencies]
Expand Down
1 change: 0 additions & 1 deletion commands/gng-build/src/agent_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use gng_build_shared::constants::container as cc;
use gng_build_shared::constants::environment as ce;
use gng_contained_command::{Binding, Runner, RunnerBuilder};

use std::convert::TryFrom;
use std::io::{BufRead, BufReader};
use std::path::{Path, PathBuf};

Expand Down
6 changes: 3 additions & 3 deletions commands/gng-repo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "gng-repo"
version = "0.1.0"
edition = "2018"
edition = "2021"
authors = ["Tobias Hunger <tobias.hunger@gmail.com>"]
license = "GPL-3.0-or-later"
categories = ["tool", "packaging", "distribution", "linux", "cleanroom" ]
keywords = ["tool", "packaging", "distribution", "linux", "cleanroom" ]
categories = ["tool", "packaging", "distribution", "linux", "cleanroom"]
keywords = ["tool", "packaging", "distribution", "linux", "cleanroom"]
repository = "https://github.com/hunger/gng"

[dependencies]
Expand Down
7 changes: 5 additions & 2 deletions crates/gng_build_shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
name = "gng_build_shared"
version = "0.1.0"
authors = ["Tobias Hunger <tobias.hunger@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
edition = "2021"
license = "GPL-3.0-or-later"
categories = ["tool", "packaging", "distribution", "linux", "cleanroom"]
keywords = ["tool", "packaging", "distribution", "linux", "cleanroom"]
repository = "https://github.com/hunger/gng"

[dependencies]
gng_core = { path = "../gng_core" }
Expand Down
4 changes: 2 additions & 2 deletions crates/gng_build_shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub enum MessageType {
Test,
}

impl std::convert::TryFrom<String> for MessageType {
impl TryFrom<String> for MessageType {
type Error = String;

fn try_from(value: String) -> Result<Self, Self::Error> {
Expand All @@ -86,7 +86,7 @@ impl std::convert::TryFrom<String> for MessageType {
}
}

impl std::convert::From<&MessageType> for String {
impl From<&MessageType> for String {
fn from(mt: &MessageType) -> Self {
match mt {
MessageType::Data => Self::from("DATA"),
Expand Down
6 changes: 5 additions & 1 deletion crates/gng_contained_command/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
name = "gng_contained_command"
version = "0.1.0"
authors = ["Tobias Hunger <tobias.hunger@gmail.com>"]
edition = "2018"
edition = "2021"
license = "GPL-3.0-or-later"
categories = ["tool", "packaging", "distribution", "linux", "cleanroom"]
keywords = ["tool", "packaging", "distribution", "linux", "cleanroom"]
repository = "https://github.com/hunger/gng"

[dependencies]
gng_core = { path = "../gng_core" }
Expand Down
2 changes: 1 addition & 1 deletion crates/gng_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "gng_core"
version = "0.1.0"
edition = "2018"
edition = "2021"
authors = ["Tobias Hunger <tobias.hunger@gmail.com>"]
license = "GPL-3.0-or-later"
categories = ["tool", "packaging", "distribution", "linux", "cleanroom"]
Expand Down
21 changes: 9 additions & 12 deletions crates/gng_core/src/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,21 @@ impl Name {
}
}

impl std::convert::From<Name> for String {
impl From<Name> for String {
fn from(name: Name) -> Self {
name.0
}
}

impl std::convert::TryFrom<&str> for Name {
impl TryFrom<&str> for Name {
type Error = crate::Error;

fn try_from(value: &str) -> Result<Self, Self::Error> {
Self::new(value)
}
}

impl std::convert::TryFrom<String> for Name {
impl TryFrom<String> for Name {
type Error = crate::Error;

fn try_from(value: String) -> Result<Self, Self::Error> {
Expand Down Expand Up @@ -136,27 +136,27 @@ impl Names {
}
}

impl std::convert::From<Names> for Vec<String> {
impl From<Names> for Vec<String> {
fn from(names: Names) -> Self {
names.0.iter().map(Name::to_string).collect()
}
}

impl std::convert::From<Name> for Names {
impl From<Name> for Names {
fn from(name: Name) -> Self {
Self(vec![name])
}
}

impl std::convert::From<&[Name]> for Names {
impl From<&[Name]> for Names {
fn from(names: &[Name]) -> Self {
let mut result = Self(names.to_vec());
result.fix();
result
}
}

impl std::convert::TryFrom<Vec<&str>> for Names {
impl TryFrom<Vec<&str>> for Names {
type Error = crate::Error;

fn try_from(values: Vec<&str>) -> Result<Self, Self::Error> {
Expand All @@ -169,7 +169,7 @@ impl std::convert::TryFrom<Vec<&str>> for Names {
}
}

impl std::convert::TryFrom<&[String]> for Names {
impl TryFrom<&[String]> for Names {
type Error = crate::Error;

fn try_from(values: &[String]) -> Result<Self, Self::Error> {
Expand All @@ -182,7 +182,7 @@ impl std::convert::TryFrom<&[String]> for Names {
}
}

impl std::convert::TryFrom<Vec<String>> for Names {
impl TryFrom<Vec<String>> for Names {
type Error = crate::Error;

fn try_from(values: Vec<String>) -> Result<Self, Self::Error> {
Expand Down Expand Up @@ -214,9 +214,6 @@ impl<'a> IntoIterator for &'a Names {
#[cfg(test)]
#[allow(clippy::non_ascii_literal)]
mod tests {
use std::convert::From;
use std::convert::TryFrom;

use super::Name;

// Name:
Expand Down
9 changes: 3 additions & 6 deletions crates/gng_core/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ impl Version {
}
}

impl std::convert::From<Version> for String {
impl From<Version> for String {
fn from(version: Version) -> Self {
format!("{:}", &version)
}
}

impl std::convert::TryFrom<&str> for Version {
impl TryFrom<&str> for Version {
type Error = crate::Error;

fn try_from(value: &str) -> Result<Self, Self::Error> {
Expand Down Expand Up @@ -137,7 +137,7 @@ impl std::convert::TryFrom<&str> for Version {
}
}

impl std::convert::TryFrom<String> for Version {
impl TryFrom<String> for Version {
type Error = crate::Error;

fn try_from(value: String) -> Result<Self, Self::Error> {
Expand Down Expand Up @@ -190,9 +190,6 @@ impl Ord for Version {
#[cfg(test)]
#[allow(clippy::non_ascii_literal)]
mod tests {
use std::convert::From;
use std::convert::TryFrom;

use super::Version;

// Version:
Expand Down
9 changes: 6 additions & 3 deletions crates/gng_package/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[package]
name = "gng_package"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
authors = ["Tobias Hunger <tobias.hunger@gmail.com>"]
edition = "2021"
license = "GPL-3.0-or-later"
categories = ["tool", "packaging", "distribution", "linux", "cleanroom"]
keywords = ["tool", "packaging", "distribution", "linux", "cleanroom"]
repository = "https://github.com/hunger/gng"

[dependencies]
gng_core = { path = "../gng_core" }
Expand Down
7 changes: 5 additions & 2 deletions crates/gng_packet_db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
name = "gng_packet_db"
version = "0.1.0"
authors = ["Tobias Hunger <tobias.hunger@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
edition = "2021"
license = "GPL-3.0-or-later"
categories = ["tool", "packaging", "distribution", "linux", "cleanroom"]
keywords = ["tool", "packaging", "distribution", "linux", "cleanroom"]
repository = "https://github.com/hunger/gng"

[dependencies]
gng_core = { path = "../gng_core" }
Expand Down
6 changes: 5 additions & 1 deletion crates/gng_packet_io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
name = "gng_packet_io"
version = "0.1.0"
authors = ["Tobias Hunger <tobias.hunger@gmail.com>"]
edition = "2018"
edition = "2021"
license = "GPL-3.0-or-later"
categories = ["tool", "packaging", "distribution", "linux", "cleanroom"]
keywords = ["tool", "packaging", "distribution", "linux", "cleanroom"]
repository = "https://github.com/hunger/gng"

[dependencies]
gng_core = { path = "../gng_core" }
Expand Down
2 changes: 1 addition & 1 deletion crates/gng_packet_io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pub use packet_writer::PacketWriter;
mod tests {
use gng_core::{Name, Version};

use std::{convert::TryFrom, io::Read};
use std::io::Read;

use crate::ContentInfo;

Expand Down
3 changes: 1 addition & 2 deletions crates/gng_packet_io/src/packet_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

use eyre::{eyre, WrapErr};

use std::io::Read;
use std::{convert::TryFrom, io::Write};
use std::io::{Read, Write};

use crate::BinaryPacketDefinition;

Expand Down

0 comments on commit 67255a4

Please sign in to comment.