fix: clippy errors

This commit is contained in:
Kristofers Solo 2025-09-25 11:01:22 +03:00
parent b900680235
commit 523cf95b6b
Signed by: kristoferssolo
GPG Key ID: 74FF8144483D82C8
5 changed files with 21 additions and 18 deletions

View File

@ -174,13 +174,13 @@ fn parse_default(list: &MetaList) -> Result<Option<Expr>> {
let value = meta.value()?;
let expr = value.parse::<Expr>()?;
if let Expr::Lit(expr_lit) = &expr {
if let Lit::Str(lit_str) = &expr_lit.lit {
default_expr = Some(parse_quote! {
#lit_str.to_string()
});
return Ok(());
}
if let Expr::Lit(expr_lit) = &expr
&& let Lit::Str(lit_str) = &expr_lit.lit
{
default_expr = Some(parse_quote! {
#lit_str.to_string()
});
return Ok(());
}
default_expr = Some(expr);
}

View File

@ -40,9 +40,9 @@ fn main() {
// Example assertions (adjust based on your actual file contents)
assert_eq!(json_data.key, "json key".to_string());
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.number, 456);
assert_eq!(toml_data.exists, true);
assert!(toml_data.exists);
}

View 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 {
| ^^^^^^

View File

@ -1,9 +0,0 @@
use filecaster::FromFile;
#[derive(FromFile)]
struct MyStruct {
#[from_file(unknown)]
field: i32,
}
fn main() {}

View 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);
| ^^^^^^^