Fix some clippy lints.
This commit is contained in:
parent
7b431c77d4
commit
8a80e547c6
4 changed files with 27 additions and 27 deletions
|
@ -414,7 +414,7 @@ impl<T: Iterator<Item = char>> Scanner<T> {
|
||||||
/// clone of) the same error.
|
/// clone of) the same error.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_error(&self) -> Option<ScanError> {
|
pub fn get_error(&self) -> Option<ScanError> {
|
||||||
self.error.as_ref().map(std::clone::Clone::clone)
|
self.error.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fill `self.buffer` with at least `count` characters.
|
/// Fill `self.buffer` with at least `count` characters.
|
||||||
|
@ -746,7 +746,7 @@ impl<T: Iterator<Item = char>> Scanner<T> {
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// This function returns an error if one of the key we would stale was required to be a key.
|
/// This function returns an error if one of the key we would stale was required to be a key.
|
||||||
fn stale_simple_keys(&mut self) -> ScanResult {
|
fn stale_simple_keys(&mut self) -> ScanResult {
|
||||||
for (_, sk) in self.simple_keys.iter_mut().enumerate() {
|
for sk in &mut self.simple_keys {
|
||||||
if sk.possible
|
if sk.possible
|
||||||
// If not in a flow construct, simple keys cannot span multiple lines.
|
// If not in a flow construct, simple keys cannot span multiple lines.
|
||||||
&& self.flow_level == 0
|
&& self.flow_level == 0
|
||||||
|
|
|
@ -352,11 +352,11 @@ fn test_integer_key() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_indentation_equality() {
|
fn test_indentation_equality() {
|
||||||
let four_spaces = YamlLoader::load_from_str(
|
let four_spaces = YamlLoader::load_from_str(
|
||||||
r#"
|
r"
|
||||||
hash:
|
hash:
|
||||||
with:
|
with:
|
||||||
indentations
|
indentations
|
||||||
"#,
|
",
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -364,11 +364,11 @@ hash:
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let two_spaces = YamlLoader::load_from_str(
|
let two_spaces = YamlLoader::load_from_str(
|
||||||
r#"
|
r"
|
||||||
hash:
|
hash:
|
||||||
with:
|
with:
|
||||||
indentations
|
indentations
|
||||||
"#,
|
",
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -376,11 +376,11 @@ hash:
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let one_space = YamlLoader::load_from_str(
|
let one_space = YamlLoader::load_from_str(
|
||||||
r#"
|
r"
|
||||||
hash:
|
hash:
|
||||||
with:
|
with:
|
||||||
indentations
|
indentations
|
||||||
"#,
|
",
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -388,11 +388,11 @@ hash:
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let mixed_spaces = YamlLoader::load_from_str(
|
let mixed_spaces = YamlLoader::load_from_str(
|
||||||
r#"
|
r"
|
||||||
hash:
|
hash:
|
||||||
with:
|
with:
|
||||||
indentations
|
indentations
|
||||||
"#,
|
",
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -408,7 +408,7 @@ hash:
|
||||||
fn test_two_space_indentations() {
|
fn test_two_space_indentations() {
|
||||||
// https://github.com/kbknapp/clap-rs/issues/965
|
// https://github.com/kbknapp/clap-rs/issues/965
|
||||||
|
|
||||||
let s = r#"
|
let s = r"
|
||||||
subcommands:
|
subcommands:
|
||||||
- server:
|
- server:
|
||||||
about: server related commands
|
about: server related commands
|
||||||
|
@ -418,7 +418,7 @@ subcommands2:
|
||||||
subcommands3:
|
subcommands3:
|
||||||
- server:
|
- server:
|
||||||
about: server related commands
|
about: server related commands
|
||||||
"#;
|
";
|
||||||
|
|
||||||
let out = YamlLoader::load_from_str(s).unwrap();
|
let out = YamlLoader::load_from_str(s).unwrap();
|
||||||
let doc = &out.into_iter().next().unwrap();
|
let doc = &out.into_iter().next().unwrap();
|
||||||
|
|
|
@ -36,7 +36,7 @@ a4:
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_emit_complex() {
|
fn test_emit_complex() {
|
||||||
let s = r#"
|
let s = r"
|
||||||
cataloge:
|
cataloge:
|
||||||
product: &coffee { name: Coffee, price: 2.5 , unit: 1l }
|
product: &coffee { name: Coffee, price: 2.5 , unit: 1l }
|
||||||
product: &cookies { name: Cookies!, price: 3.40 , unit: 400g}
|
product: &cookies { name: Cookies!, price: 3.40 , unit: 400g}
|
||||||
|
@ -54,7 +54,7 @@ products:
|
||||||
bool key
|
bool key
|
||||||
{}:
|
{}:
|
||||||
empty hash key
|
empty hash key
|
||||||
"#;
|
";
|
||||||
let docs = YamlLoader::load_from_str(s).unwrap();
|
let docs = YamlLoader::load_from_str(s).unwrap();
|
||||||
let doc = &docs[0];
|
let doc = &docs[0];
|
||||||
let mut writer = String::new();
|
let mut writer = String::new();
|
||||||
|
@ -66,8 +66,8 @@ products:
|
||||||
Ok(y) => y,
|
Ok(y) => y,
|
||||||
Err(e) => panic!("{}", e),
|
Err(e) => panic!("{}", e),
|
||||||
};
|
};
|
||||||
let doc_new = &docs_new[0];
|
let new_doc = &docs_new[0];
|
||||||
assert_eq!(doc, doc_new);
|
assert_eq!(doc, new_doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -190,7 +190,7 @@ fn test_empty_and_nested_compact() {
|
||||||
|
|
||||||
fn test_empty_and_nested_flag(compact: bool) {
|
fn test_empty_and_nested_flag(compact: bool) {
|
||||||
let s = if compact {
|
let s = if compact {
|
||||||
r#"---
|
r"---
|
||||||
a:
|
a:
|
||||||
b:
|
b:
|
||||||
c: hello
|
c: hello
|
||||||
|
@ -198,9 +198,9 @@ a:
|
||||||
e:
|
e:
|
||||||
- f
|
- f
|
||||||
- g
|
- g
|
||||||
- h: []"#
|
- h: []"
|
||||||
} else {
|
} else {
|
||||||
r#"---
|
r"---
|
||||||
a:
|
a:
|
||||||
b:
|
b:
|
||||||
c: hello
|
c: hello
|
||||||
|
@ -209,7 +209,7 @@ e:
|
||||||
- f
|
- f
|
||||||
- g
|
- g
|
||||||
-
|
-
|
||||||
h: []"#
|
h: []"
|
||||||
};
|
};
|
||||||
|
|
||||||
let docs = YamlLoader::load_from_str(s).unwrap();
|
let docs = YamlLoader::load_from_str(s).unwrap();
|
||||||
|
@ -226,13 +226,13 @@ e:
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_nested_arrays() {
|
fn test_nested_arrays() {
|
||||||
let s = r#"---
|
let s = r"---
|
||||||
a:
|
a:
|
||||||
- b
|
- b
|
||||||
- - c
|
- - c
|
||||||
- d
|
- d
|
||||||
- - e
|
- - e
|
||||||
- f"#;
|
- f";
|
||||||
|
|
||||||
let docs = YamlLoader::load_from_str(s).unwrap();
|
let docs = YamlLoader::load_from_str(s).unwrap();
|
||||||
let doc = &docs[0];
|
let doc = &docs[0];
|
||||||
|
@ -249,14 +249,14 @@ a:
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_deeply_nested_arrays() {
|
fn test_deeply_nested_arrays() {
|
||||||
let s = r#"---
|
let s = r"---
|
||||||
a:
|
a:
|
||||||
- b
|
- b
|
||||||
- - c
|
- - c
|
||||||
- d
|
- d
|
||||||
- - e
|
- - e
|
||||||
- - f
|
- - f
|
||||||
- - e"#;
|
- - e";
|
||||||
|
|
||||||
let docs = YamlLoader::load_from_str(s).unwrap();
|
let docs = YamlLoader::load_from_str(s).unwrap();
|
||||||
let doc = &docs[0];
|
let doc = &docs[0];
|
||||||
|
@ -273,12 +273,12 @@ a:
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_nested_hashes() {
|
fn test_nested_hashes() {
|
||||||
let s = r#"---
|
let s = r"---
|
||||||
a:
|
a:
|
||||||
b:
|
b:
|
||||||
c:
|
c:
|
||||||
d:
|
d:
|
||||||
e: f"#;
|
e: f";
|
||||||
|
|
||||||
let docs = YamlLoader::load_from_str(s).unwrap();
|
let docs = YamlLoader::load_from_str(s).unwrap();
|
||||||
let doc = &docs[0];
|
let doc = &docs[0];
|
||||||
|
|
|
@ -80,7 +80,7 @@ fn load_tests_from_file(entry: &DirEntry) -> Result<Vec<Test<YamlTest>>> {
|
||||||
let test_name = file_name
|
let test_name = file_name
|
||||||
.strip_suffix(".yaml")
|
.strip_suffix(".yaml")
|
||||||
.ok_or("unexpected filename")?;
|
.ok_or("unexpected filename")?;
|
||||||
let tests = YamlLoader::load_from_str(&fs::read_to_string(&entry.path())?)?;
|
let tests = YamlLoader::load_from_str(&fs::read_to_string(entry.path())?)?;
|
||||||
let tests = tests[0].as_vec().ok_or("no test list found in file")?;
|
let tests = tests[0].as_vec().ok_or("no test list found in file")?;
|
||||||
|
|
||||||
let mut result = vec![];
|
let mut result = vec![];
|
||||||
|
|
Loading…
Reference in a new issue