Skip to content
This repository has been archived by the owner on Jun 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request #592 from QE-Lab/remove-named-type-dep
Browse files Browse the repository at this point in the history
Remove named_type dependency
  • Loading branch information
mbrobbel authored Jul 2, 2020
2 parents ba6ad3c + c9f4149 commit d905e3d
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 45 deletions.
19 changes: 0 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ bindings = ["cbindgen", "libc", "regex", "lazy_static"]
[dependencies]
strum = "0.18"
strum_macros = "0.18"
named_type = "0.2"
named_type_derive = "0.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_cbor = "0.11"
Expand Down
4 changes: 0 additions & 4 deletions rust/src/core/common/log/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ use crate::common::{
error::{ErrorKind, ResultExt},
};
use lazy_static::lazy_static;
use named_type::NamedType;
use named_type_derive::*;
use ref_thread_local::ref_thread_local;
use serde::{Deserialize, Serialize};
use std::{cell::RefCell, fmt};
Expand Down Expand Up @@ -194,7 +192,6 @@ ref_thread_local! {
EnumString,
Display,
EnumIter,
NamedType,
)]
pub enum Loglevel {
/// This loglevel is to be used for reporting a fatal error, resulting from
Expand Down Expand Up @@ -266,7 +263,6 @@ impl Into<term::color::Color> for Loglevel {
EnumString,
Display,
EnumIter,
NamedType,
)]
pub enum LoglevelFilter {
/// A level lower than all log levels.
Expand Down
13 changes: 4 additions & 9 deletions rust/src/core/common/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,7 @@ pub fn friendly_enumerate(
/// error messages generated are user-friendly as well.
pub fn friendly_enum_parse<E, I>(s: &str) -> Result<E>
where
E: std::str::FromStr
+ strum::IntoEnumIterator<Iterator = I>
+ named_type::NamedType
+ std::fmt::Display,
E: std::str::FromStr + strum::IntoEnumIterator<Iterator = I> + std::fmt::Display,
I: Iterator<Item = E>,
{
// Match using a lowercase version of the provided string, so we match
Expand All @@ -235,7 +232,7 @@ where
0 => inv_arg(format!(
"{} is not a valid {}, valid values are {}",
s,
friendly_name(E::short_type_name()),
friendly_name(std::any::type_name::<E>().rsplit("::").next().unwrap()),
friendly_enumerate(
E::iter().map(|e| format!("{}", e).to_lowercase()),
Some("or")
Expand All @@ -245,7 +242,7 @@ where
_ => inv_arg(format!(
"{} is an ambiguous {}, it could mean either {}",
s,
friendly_name(E::short_type_name()),
friendly_name(std::any::type_name::<E>().rsplit("::").next().unwrap()),
friendly_enumerate(matches.into_iter().map(|x| x.0), Some("or"))
)),
}
Expand All @@ -254,13 +251,11 @@ where
#[cfg(test)]
mod tests {
use super::*;
use named_type::NamedType;
use named_type_derive::*;
use std::str::FromStr;
use strum::ParseError;
use strum_macros::{Display, EnumIter, EnumString};

#[derive(NamedType, Display, EnumIter, EnumString, Clone, PartialEq, Debug)]
#[derive(Display, EnumIter, EnumString, Clone, PartialEq, Debug)]
enum TestEnum {
#[strum(to_string = "Foo", serialize = "foo", serialize = "f")]
Foo,
Expand Down
6 changes: 1 addition & 5 deletions rust/src/core/host/configuration/reproduction_path_style.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use named_type::NamedType;
use named_type_derive::*;
use serde::{Deserialize, Serialize};
use std::{
env::current_dir,
Expand All @@ -9,9 +7,7 @@ use std::{
use strum_macros::{Display, EnumIter, EnumString};

/// Represents the style for storing paths in a reproduction file.
#[derive(
Display, EnumIter, EnumString, NamedType, Debug, Clone, Copy, PartialEq, Deserialize, Serialize,
)]
#[derive(Display, EnumIter, EnumString, Debug, Clone, Copy, PartialEq, Deserialize, Serialize)]
pub enum ReproductionPathStyle {
/// Specifies that paths should be saved the same way they were specified
/// on the command line.
Expand Down
4 changes: 1 addition & 3 deletions rust/src/core/host/configuration/stream_capture_mode.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use crate::common::{error::Error, log::Loglevel, util::friendly_enum_parse};
use named_type::NamedType;
use named_type_derive::*;
use serde::{Deserialize, Serialize};
use std::process::Stdio;
use strum_macros::{Display, EnumIter, EnumString};

/// All loglevel options plus pass and null, used to specify how a
/// stdout/stderr stream should be captured.
#[derive(Display, EnumIter, EnumString, NamedType, Debug, Copy, Clone, PartialEq)]
#[derive(Display, EnumIter, EnumString, Debug, Copy, Clone, PartialEq)]
enum StreamCaptureOption {
Pass,
Null,
Expand Down
4 changes: 1 addition & 3 deletions rust/src/core/host/reproduction/host_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ use crate::common::{
types::{ArbCmd, ArbData},
util::friendly_enum_parse,
};
use named_type::NamedType;
use named_type_derive::*;
use serde::{Deserialize, Serialize};
use strum_macros::{Display, EnumIter, EnumString};

/// Represents a host API call name.
#[derive(Display, NamedType, EnumIter, EnumString, Debug, Copy, Clone, PartialEq)]
#[derive(Display, EnumIter, EnumString, Debug, Copy, Clone, PartialEq)]
#[strum(serialize_all = "snake_case")]
enum HostCallFunction {
Start,
Expand Down

0 comments on commit d905e3d

Please sign in to comment.