mirror of
https://github.com/kristoferssolo/filecaster.git
synced 2025-10-21 19:00:34 +00:00
fix: clippy errors
This commit is contained in:
parent
b900680235
commit
523cf95b6b
@ -174,13 +174,13 @@ fn parse_default(list: &MetaList) -> Result<Option<Expr>> {
|
|||||||
let value = meta.value()?;
|
let value = meta.value()?;
|
||||||
let expr = value.parse::<Expr>()?;
|
let expr = value.parse::<Expr>()?;
|
||||||
|
|
||||||
if let Expr::Lit(expr_lit) = &expr {
|
if let Expr::Lit(expr_lit) = &expr
|
||||||
if let Lit::Str(lit_str) = &expr_lit.lit {
|
&& let Lit::Str(lit_str) = &expr_lit.lit
|
||||||
default_expr = Some(parse_quote! {
|
{
|
||||||
#lit_str.to_string()
|
default_expr = Some(parse_quote! {
|
||||||
});
|
#lit_str.to_string()
|
||||||
return Ok(());
|
});
|
||||||
}
|
return Ok(());
|
||||||
}
|
}
|
||||||
default_expr = Some(expr);
|
default_expr = Some(expr);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,9 +40,9 @@ fn main() {
|
|||||||
// Example assertions (adjust based on your actual file contents)
|
// Example assertions (adjust based on your actual file contents)
|
||||||
assert_eq!(json_data.key, "json key".to_string());
|
assert_eq!(json_data.key, "json key".to_string());
|
||||||
assert_eq!(json_data.number, 123);
|
assert_eq!(json_data.number, 123);
|
||||||
assert_eq!(json_data.exists, false); // `bool::default()` is `false`
|
assert!(!json_data.exists); // `bool::default()` is `false`
|
||||||
|
|
||||||
assert_eq!(toml_data.key, "default key".to_string());
|
assert_eq!(toml_data.key, "default key".to_string());
|
||||||
assert_eq!(toml_data.number, 456);
|
assert_eq!(toml_data.number, 456);
|
||||||
assert_eq!(toml_data.exists, true);
|
assert!(toml_data.exists);
|
||||||
}
|
}
|
||||||
|
|||||||
6
filecaster/tests/ui/enum_not_supported.stderr
Normal file
6
filecaster/tests/ui/enum_not_supported.stderr
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
error: FromFile only works on structs.
|
||||||
|
Enums are not supported.
|
||||||
|
--> tests/ui/enum_not_supported.rs:4:6
|
||||||
|
|
|
||||||
|
4 | enum MyEnum {
|
||||||
|
| ^^^^^^
|
||||||
@ -1,9 +0,0 @@
|
|||||||
use filecaster::FromFile;
|
|
||||||
|
|
||||||
#[derive(FromFile)]
|
|
||||||
struct MyStruct {
|
|
||||||
#[from_file(unknown)]
|
|
||||||
field: i32,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
6
filecaster/tests/ui/tuple_struct_not_supported.stderr
Normal file
6
filecaster/tests/ui/tuple_struct_not_supported.stderr
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
error: FromFile only works on structs with *named* fields.
|
||||||
|
Tuple structs and unit structs are not supported.
|
||||||
|
--> tests/ui/tuple_struct_not_supported.rs:4:8
|
||||||
|
|
|
||||||
|
4 | struct MyTuple(i32, String);
|
||||||
|
| ^^^^^^^
|
||||||
Loading…
Reference in New Issue
Block a user