Skip to content

Commit 84eec4d

Browse files
committed
Format code using 'cargo fmt'
1 parent 33bd4f9 commit 84eec4d

Some content is hidden

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

122 files changed

+3440
-2621
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,
@@ -140,8 +139,7 @@ impl FromStr for Metadata {
140139
type Err = Error;
141140

142141
fn from_str(code: &str) -> Result<Metadata> {
143-
let (_, lines) = metalines(code)
144-
.map_err(|_| format_err!("Failed to parse header"))?;
142+
let (_, lines) = metalines(code).map_err(|_| format_err!("Failed to parse header"))?;
145143

146144
let mut data = NewMetadata::default();
147145

@@ -170,16 +168,20 @@ pub struct NewMetadata<'a> {
170168

171169
impl<'a> NewMetadata<'a> {
172170
fn try_from(self) -> Result<Metadata> {
173-
let description = self.description.ok_or_else(|| format_err!("Description is required"))?;
174-
let version = self.version.ok_or_else(|| format_err!("Version is required"))?;
171+
let description = self
172+
.description
173+
.ok_or_else(|| format_err!("Description is required"))?;
174+
let version = self
175+
.version
176+
.ok_or_else(|| format_err!("Version is required"))?;
175177
let source = match self.source {
176178
Some(x) => Some(x.parse()?),
177179
_ => None,
178180
};
179-
let keyring_access = self.keyring_access.into_iter()
180-
.map(String::from)
181-
.collect();
182-
let license = self.license.ok_or_else(|| format_err!("License is required"))?;
181+
let keyring_access = self.keyring_access.into_iter().map(String::from).collect();
182+
let license = self
183+
.license
184+
.ok_or_else(|| format_err!("License is required"))?;
183185
let license = license.parse()?;
184186

185187
Ok(Metadata {
@@ -216,55 +218,71 @@ mod tests {
216218

217219
#[test]
218220
fn verify_simple() {
219-
let metadata = Metadata::from_str(r#"-- Description: Hello world, this is my description
221+
let metadata = Metadata::from_str(
222+
r#"-- Description: Hello world, this is my description
220223
-- Version: 1.0.0
221224
-- Source: domains
222225
-- License: WTFPL
223226
224-
"#).expect("parse");
225-
assert_eq!(metadata, Metadata {
226-
description: "Hello world, this is my description".to_string(),
227-
version: "1.0.0".to_string(),
228-
license: License::WTFPL,
229-
source: Some(Source::Domains),
230-
keyring_access: Vec::new(),
231-
});
227+
"#,
228+
)
229+
.expect("parse");
230+
assert_eq!(
231+
metadata,
232+
Metadata {
233+
description: "Hello world, this is my description".to_string(),
234+
version: "1.0.0".to_string(),
235+
license: License::WTFPL,
236+
source: Some(Source::Domains),
237+
keyring_access: Vec::new(),
238+
}
239+
);
232240
}
233241

234242
#[test]
235243
fn verify_no_source() {
236-
let metadata = Metadata::from_str(r#"-- Description: Hello world, this is my description
244+
let metadata = Metadata::from_str(
245+
r#"-- Description: Hello world, this is my description
237246
-- Version: 1.0.0
238247
-- License: WTFPL
239248
240-
"#).expect("parse");
241-
assert_eq!(metadata, Metadata {
242-
description: "Hello world, this is my description".to_string(),
243-
version: "1.0.0".to_string(),
244-
license: License::WTFPL,
245-
source: None,
246-
keyring_access: Vec::new(),
247-
});
249+
"#,
250+
)
251+
.expect("parse");
252+
assert_eq!(
253+
metadata,
254+
Metadata {
255+
description: "Hello world, this is my description".to_string(),
256+
version: "1.0.0".to_string(),
257+
license: License::WTFPL,
258+
source: None,
259+
keyring_access: Vec::new(),
260+
}
261+
);
248262
}
249263

250264
#[test]
251265
fn verify_require_license() {
252-
let metadata = Metadata::from_str(r#"-- Description: Hello world, this is my description
266+
let metadata = Metadata::from_str(
267+
r#"-- Description: Hello world, this is my description
253268
-- Version: 1.0.0
254269
-- Source: domains
255270
256-
"#);
271+
"#,
272+
);
257273
assert!(metadata.is_err());
258274
}
259275

260276
#[test]
261277
fn verify_require_opensource_license() {
262-
let metadata = Metadata::from_str(r#"-- Description: Hello world, this is my description
278+
let metadata = Metadata::from_str(
279+
r#"-- Description: Hello world, this is my description
263280
-- Version: 1.0.0
264281
-- Source: domains
265282
-- License: Proprietary
266283
267-
"#);
284+
"#,
285+
);
268286
assert!(metadata.is_err());
269287
}
270288

0 commit comments

Comments
 (0)