Skip to content

Commit cf518f6

Browse files
committed
Auto merge of #595 - Mark-Simulacrum:cleanup-deps, r=Mark-Simulacrum
Cleanup deps Drops paste entirely, removes tokio + futures deps from Cargo.toml (still transitive deps).
2 parents 864080b + d709a88 commit cf518f6

File tree

6 files changed

+23
-66
lines changed

6 files changed

+23
-66
lines changed

Cargo.lock

Lines changed: 0 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@ csv = "1.0.2"
2323
dotenv = "0.13"
2424
failure = "0.1.3"
2525
flate2 = "1"
26-
futures = "0.1.13"
2726
http = "0.1.10"
2827
hyper = "0.12.8"
2928
lazy_static = "1.0"
3029
mime = "0.3.1"
3130
minifier = { version = "0.0.20", features = ["html"] }
32-
paste = "0.1.3"
3331
petgraph = "0.4.11"
3432
r2d2 = "0.8.2"
3533
r2d2_sqlite = "0.19.0"
@@ -49,7 +47,6 @@ structopt-derive = "0.2"
4947
tar = "0.4.0"
5048
tempfile = "3.0.0"
5149
tera = "0.11.7"
52-
tokio = "0.1.11"
5350
toml = "0.4.6"
5451
url = "1.1"
5552
walkdir = "2"

src/experiments.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ string_enum!(pub enum CapLints {
4444

4545
const SMALL_RANDOM_COUNT: u32 = 20;
4646

47-
#[derive(Debug, PartialEq, Eq, Clone)]
47+
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
48+
#[serde(try_from = "String", into = "String")]
4849
pub enum CrateSelect {
4950
Full,
5051
Demo,
@@ -55,6 +56,8 @@ pub enum CrateSelect {
5556
List(HashSet<String>),
5657
}
5758

59+
from_into_string!(CrateSelect);
60+
5861
impl FromStr for CrateSelect {
5962
type Err = failure::Error;
6063

@@ -167,8 +170,6 @@ impl FromStr for DeferredCrateSelect {
167170
}
168171
}
169172

170-
impl_serde_from_parse!(CrateSelect, expecting = "A valid value of `CrateSelect`");
171-
172173
#[cfg_attr(test, derive(Debug, PartialEq, Eq))]
173174
#[derive(Clone, Serialize, Deserialize)]
174175
pub enum Assignee {

src/results/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ macro_rules! test_result_enum {
115115
with_reason { $($with_reason_name:ident($reason:ident) => $with_reason_repr:expr,)* }
116116
without_reason { $($reasonless_name:ident => $reasonless_repr:expr,)* }
117117
}) => {
118-
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
118+
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize)]
119+
#[serde(try_from = "String", into = "String")]
119120
pub enum $name {
120121
$($with_reason_name($reason),)*
121122
$($reasonless_name,)*
@@ -301,7 +302,7 @@ test_result_enum!(pub enum TestResult {
301302
}
302303
});
303304

304-
impl_serde_from_parse!(TestResult, expecting = "a test result");
305+
from_into_string!(TestResult);
305306

306307
#[cfg(test)]
307308
mod tests {

src/utils/macros.rs

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
macro_rules! string_enum {
22
($vis:vis enum $name:ident { $($item:ident => $str:expr,)* }) => {
3-
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)]
3+
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, Serialize, Deserialize)]
4+
#[serde(try_from = "String", into = "String")]
45
$vis enum $name {
56
$($item,)*
67
}
@@ -36,44 +37,22 @@ macro_rules! string_enum {
3637
}
3738
}
3839

39-
impl_serde_from_parse!($name, expecting="foo");
40+
from_into_string!($name);
4041
}
4142
}
4243

43-
macro_rules! impl_serde_from_parse {
44-
($for:ident, expecting=$expecting:expr) => {
45-
paste::item! {
46-
struct [<$for Visitor>];
47-
48-
impl<'de> ::serde::de::Visitor<'de> for [<$for Visitor>] {
49-
type Value = $for;
50-
51-
fn expecting(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
52-
f.write_str($expecting)
53-
}
54-
55-
fn visit_str<E: ::serde::de::Error>(self, input: &str) -> Result<$for, E> {
56-
use std::str::FromStr;
57-
$for::from_str(input).map_err(E::custom)
58-
}
59-
}
60-
}
61-
62-
impl<'de> ::serde::de::Deserialize<'de> for $for {
63-
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
64-
where
65-
D: ::serde::de::Deserializer<'de>,
66-
{
67-
deserializer.deserialize_str(paste::expr! { [<$for Visitor>] })
44+
macro_rules! from_into_string {
45+
($for:ident) => {
46+
impl std::convert::TryFrom<String> for $for {
47+
type Error = <$for as std::str::FromStr>::Err;
48+
fn try_from(s: String) -> Result<Self, <$for as std::str::FromStr>::Err> {
49+
s.parse()
6850
}
6951
}
7052

71-
impl ::serde::ser::Serialize for $for {
72-
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
73-
where
74-
S: ::serde::ser::Serializer,
75-
{
76-
serializer.serialize_str(&self.to_string())
53+
impl From<$for> for String {
54+
fn from(s: $for) -> String {
55+
s.to_string()
7756
}
7857
}
7958
};

src/utils/size.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use crate::prelude::*;
22
use std::fmt;
33
use std::str::FromStr;
44

5-
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
5+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
6+
#[serde(try_from = "String", into = "String")]
67
pub enum Size {
78
Bytes(usize),
89
Kilobytes(usize),
@@ -11,6 +12,8 @@ pub enum Size {
1112
Terabytes(usize),
1213
}
1314

15+
from_into_string!(Size);
16+
1417
impl Size {
1518
pub(crate) fn to_bytes(&self) -> usize {
1619
match self {
@@ -61,8 +64,6 @@ impl FromStr for Size {
6164
}
6265
}
6366

64-
impl_serde_from_parse!(Size, expecting = "a size");
65-
6667
#[cfg(test)]
6768
mod tests {
6869
use super::Size;

0 commit comments

Comments
 (0)