Skip to content

Commit c18e137

Browse files
committed
Format code using 'cargo fmt'
1 parent da0e6aa commit c18e137

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+3683
-2734
lines changed

examples/boxxy.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#[macro_use] extern crate boxxy;
2-
extern crate sn0int;
1+
#[macro_use]
2+
extern crate boxxy;
33
extern crate env_logger;
4+
extern crate sn0int;
45

56
fn stage1(sh: &mut boxxy::Shell, _args: Vec<String>) -> Result<(), boxxy::Error> {
67
shprintln!(sh, "[*] starting stage1");
@@ -14,8 +15,6 @@ fn main() {
1415

1516
println!("stage1 activate sandbox");
1617

17-
let toolbox = boxxy::Toolbox::new().with(vec![
18-
("stage1", stage1),
19-
]);
18+
let toolbox = boxxy::Toolbox::new().with(vec![("stage1", stage1)]);
2019
boxxy::Shell::new(toolbox).run()
2120
}

examples/maxmind.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use structopt::StructOpt;
77

88
#[derive(Debug, StructOpt)]
99
pub enum Args {
10-
#[structopt(name="asn")]
10+
#[structopt(name = "asn")]
1111
Asn(AsnArgs),
12-
#[structopt(name="geoip")]
12+
#[structopt(name = "geoip")]
1313
GeoIP(GeoIPArgs),
1414
}
1515

@@ -47,7 +47,6 @@ impl GeoIPArgs {
4747
}
4848
}
4949

50-
5150
fn run() -> Result<()> {
5251
let args = Args::from_args();
5352
debug!("{:?}", args);

examples/spinners.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1+
use sn0int::term::{Spinner, StackedSpinners, SPINNERS};
12
use std::thread;
23
use std::time::Duration;
3-
use sn0int::term::{SPINNERS, Spinner, StackedSpinners};
44
use structopt::StructOpt;
55

6-
76
#[derive(Debug, StructOpt)]
87
pub enum Args {
9-
#[structopt(name="single")]
8+
#[structopt(name = "single")]
109
Single(Single),
11-
#[structopt(name="stacked")]
10+
#[structopt(name = "stacked")]
1211
Stacked(Stacked),
1312
}
1413

1514
#[derive(Debug, StructOpt)]
1615
pub struct Single {
1716
idx: usize,
18-
#[structopt(long="ticks", default_value="100")]
17+
#[structopt(long = "ticks", default_value = "100")]
1918
ticks: usize,
2019
}
2120

@@ -33,8 +32,7 @@ impl Single {
3332
}
3433

3534
#[derive(Debug, StructOpt)]
36-
pub struct Stacked {
37-
}
35+
pub struct Stacked {}
3836

3937
impl Stacked {
4038
fn run(&self) {

sn0int-common/src/id.rs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
use crate::errors::*;
22
use nom;
3-
use serde::{de, Serialize, Serializer, Deserialize, Deserializer};
3+
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
44
use std::fmt;
55
use std::result;
66
use std::str::FromStr;
77

8-
98
#[inline(always)]
109
fn valid_char(c: char) -> bool {
1110
nom::character::is_alphanumeric(c as u8) || c == '-'
@@ -20,15 +19,15 @@ pub fn valid_name(name: &str) -> Result<()> {
2019
}
2120

2221
fn module(s: &str) -> nom::IResult<&str, ModuleID> {
23-
let (input, (author, _, name)) = nom::sequence::tuple((
24-
token,
25-
nom::bytes::complete::tag("/"),
26-
token,
27-
))(s)?;
28-
Ok((input, ModuleID {
29-
author: author.to_string(),
30-
name: name.to_string(),
31-
}))
22+
let (input, (author, _, name)) =
23+
nom::sequence::tuple((token, nom::bytes::complete::tag("/"), token))(s)?;
24+
Ok((
25+
input,
26+
ModuleID {
27+
author: author.to_string(),
28+
name: name.to_string(),
29+
},
30+
))
3231
}
3332

3433
#[inline]
@@ -52,8 +51,8 @@ impl FromStr for ModuleID {
5251
type Err = Error;
5352

5453
fn from_str(s: &str) -> Result<ModuleID> {
55-
let (trailing, module) = module(s)
56-
.map_err(|err| format_err!("Failed to parse module id: {:?}", err))?;
54+
let (trailing, module) =
55+
module(s).map_err(|err| format_err!("Failed to parse module id: {:?}", err))?;
5756
if !trailing.is_empty() {
5857
bail!("Trailing data in module id");
5958
}
@@ -72,7 +71,8 @@ impl Serialize for ModuleID {
7271

7372
impl<'de> Deserialize<'de> for ModuleID {
7473
fn deserialize<D>(deserializer: D) -> result::Result<Self, D::Error>
75-
where D: Deserializer<'de>
74+
where
75+
D: Deserializer<'de>,
7676
{
7777
let s = String::deserialize(deserializer)?;
7878
FromStr::from_str(&s).map_err(de::Error::custom)
@@ -86,10 +86,13 @@ mod tests {
8686
#[test]
8787
fn verify_valid() {
8888
let result = ModuleID::from_str("kpcyrd/foo").expect("parse");
89-
assert_eq!(result, ModuleID {
90-
author: "kpcyrd".to_string(),
91-
name: "foo".to_string(),
92-
});
89+
assert_eq!(
90+
result,
91+
ModuleID {
92+
author: "kpcyrd".to_string(),
93+
name: "foo".to_string(),
94+
}
95+
);
9396
}
9497

9598
#[test]

sn0int-common/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
#[macro_use] extern crate serde_derive;
2-
#[macro_use] extern crate failure;
3-
#[macro_use] extern crate nom;
1+
#[macro_use]
2+
extern crate serde_derive;
3+
#[macro_use]
4+
extern crate failure;
5+
#[macro_use]
6+
extern crate nom;
47

58
pub mod api;
69
pub mod errors;
710
pub use crate::errors::*;
8-
pub mod metadata;
911
pub mod id;
12+
pub mod metadata;
1013
pub use crate::id::*;
1114

1215
pub use rocket_failure_errors::StrictApiResponse as ApiResponse;

sn0int-common/src/metadata.rs

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::errors::*;
22

33
use std::str::FromStr;
44

5-
65
#[derive(Debug, PartialEq, Clone)]
76
pub enum EntryType {
87
Description,
@@ -143,8 +142,7 @@ impl FromStr for Metadata {
143142
type Err = Error;
144143

145144
fn from_str(code: &str) -> Result<Metadata> {
146-
let (_, lines) = metalines(code)
147-
.map_err(|_| format_err!("Failed to parse header"))?;
145+
let (_, lines) = metalines(code).map_err(|_| format_err!("Failed to parse header"))?;
148146

149147
let mut data = NewMetadata::default();
150148

@@ -173,16 +171,20 @@ pub struct NewMetadata<'a> {
173171

174172
impl<'a> NewMetadata<'a> {
175173
fn try_from(self) -> Result<Metadata> {
176-
let description = self.description.ok_or_else(|| format_err!("Description is required"))?;
177-
let version = self.version.ok_or_else(|| format_err!("Version is required"))?;
174+
let description = self
175+
.description
176+
.ok_or_else(|| format_err!("Description is required"))?;
177+
let version = self
178+
.version
179+
.ok_or_else(|| format_err!("Version is required"))?;
178180
let source = match self.source {
179181
Some(x) => Some(x.parse()?),
180182
_ => None,
181183
};
182-
let keyring_access = self.keyring_access.into_iter()
183-
.map(String::from)
184-
.collect();
185-
let license = self.license.ok_or_else(|| format_err!("License is required"))?;
184+
let keyring_access = self.keyring_access.into_iter().map(String::from).collect();
185+
let license = self
186+
.license
187+
.ok_or_else(|| format_err!("License is required"))?;
186188
let license = license.parse()?;
187189

188190
Ok(Metadata {
@@ -219,55 +221,71 @@ mod tests {
219221

220222
#[test]
221223
fn verify_simple() {
222-
let metadata = Metadata::from_str(r#"-- Description: Hello world, this is my description
224+
let metadata = Metadata::from_str(
225+
r#"-- Description: Hello world, this is my description
223226
-- Version: 1.0.0
224227
-- Source: domains
225228
-- License: WTFPL
226229
227-
"#).expect("parse");
228-
assert_eq!(metadata, Metadata {
229-
description: "Hello world, this is my description".to_string(),
230-
version: "1.0.0".to_string(),
231-
license: License::WTFPL,
232-
source: Some(Source::Domains),
233-
keyring_access: Vec::new(),
234-
});
230+
"#,
231+
)
232+
.expect("parse");
233+
assert_eq!(
234+
metadata,
235+
Metadata {
236+
description: "Hello world, this is my description".to_string(),
237+
version: "1.0.0".to_string(),
238+
license: License::WTFPL,
239+
source: Some(Source::Domains),
240+
keyring_access: Vec::new(),
241+
}
242+
);
235243
}
236244

237245
#[test]
238246
fn verify_no_source() {
239-
let metadata = Metadata::from_str(r#"-- Description: Hello world, this is my description
247+
let metadata = Metadata::from_str(
248+
r#"-- Description: Hello world, this is my description
240249
-- Version: 1.0.0
241250
-- License: WTFPL
242251
243-
"#).expect("parse");
244-
assert_eq!(metadata, Metadata {
245-
description: "Hello world, this is my description".to_string(),
246-
version: "1.0.0".to_string(),
247-
license: License::WTFPL,
248-
source: None,
249-
keyring_access: Vec::new(),
250-
});
252+
"#,
253+
)
254+
.expect("parse");
255+
assert_eq!(
256+
metadata,
257+
Metadata {
258+
description: "Hello world, this is my description".to_string(),
259+
version: "1.0.0".to_string(),
260+
license: License::WTFPL,
261+
source: None,
262+
keyring_access: Vec::new(),
263+
}
264+
);
251265
}
252266

253267
#[test]
254268
fn verify_require_license() {
255-
let metadata = Metadata::from_str(r#"-- Description: Hello world, this is my description
269+
let metadata = Metadata::from_str(
270+
r#"-- Description: Hello world, this is my description
256271
-- Version: 1.0.0
257272
-- Source: domains
258273
259-
"#);
274+
"#,
275+
);
260276
assert!(metadata.is_err());
261277
}
262278

263279
#[test]
264280
fn verify_require_opensource_license() {
265-
let metadata = Metadata::from_str(r#"-- Description: Hello world, this is my description
281+
let metadata = Metadata::from_str(
282+
r#"-- Description: Hello world, this is my description
266283
-- Version: 1.0.0
267284
-- Source: domains
268285
-- License: Proprietary
269286
270-
"#);
287+
"#,
288+
);
271289
assert!(metadata.is_err());
272290
}
273291

0 commit comments

Comments
 (0)