Skip to content

Commit a976272

Browse files
committed
fix: clippy warnings
1 parent 3400d32 commit a976272

File tree

27 files changed

+201
-219
lines changed

27 files changed

+201
-219
lines changed

float-pigment-consistent-bincode/src/config/int.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,7 @@ fn cast_u64_to_u32(n: u64) -> Result<u32> {
642642
Ok(n as u32)
643643
} else {
644644
Err(Box::new(ErrorKind::Custom(format!(
645-
"Invalid u32 {}: you may have a version disagreement?",
646-
n,
645+
"Invalid u32 {n}: you may have a version disagreement?",
647646
))))
648647
}
649648
}
@@ -652,8 +651,7 @@ fn cast_u64_to_u16(n: u64) -> Result<u16> {
652651
Ok(n as u16)
653652
} else {
654653
Err(Box::new(ErrorKind::Custom(format!(
655-
"Invalid u16 {}: you may have a version disagreement?",
656-
n,
654+
"Invalid u16 {n}: you may have a version disagreement?",
657655
))))
658656
}
659657
}
@@ -663,8 +661,7 @@ fn cast_i64_to_i32(n: i64) -> Result<i32> {
663661
Ok(n as i32)
664662
} else {
665663
Err(Box::new(ErrorKind::Custom(format!(
666-
"Invalid i32 {}: you may have a version disagreement?",
667-
n,
664+
"Invalid i32 {n}: you may have a version disagreement?",
668665
))))
669666
}
670667
}
@@ -674,8 +671,7 @@ fn cast_i64_to_i16(n: i64) -> Result<i16> {
674671
Ok(n as i16)
675672
} else {
676673
Err(Box::new(ErrorKind::Custom(format!(
677-
"Invalid i16 {}: you may have a version disagreement?",
678-
n,
674+
"Invalid i16 {n}: you may have a version disagreement?",
679675
))))
680676
}
681677
}

float-pigment-consistent-bincode/src/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ impl From<crate::io::Error> for Error {
7171
impl fmt::Display for ErrorKind {
7272
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
7373
match *self {
74-
ErrorKind::Io(ref ioerr) => write!(fmt, "io error: {}", ioerr),
75-
ErrorKind::InvalidUtf8Encoding(ref e) => write!(fmt, "string is not valid utf8: {}", e),
74+
ErrorKind::Io(ref ioerr) => write!(fmt, "io error: {ioerr}"),
75+
ErrorKind::InvalidUtf8Encoding(ref e) => write!(fmt, "string is not valid utf8: {e}"),
7676
ErrorKind::InvalidBoolEncoding(b) => {
77-
write!(fmt, "invalid u8 while decoding bool, expected 0 or 1, found {}", b)
77+
write!(fmt, "invalid u8 while decoding bool, expected 0 or 1, found {b}")
7878
}
7979
ErrorKind::InvalidCharEncoding => write!(fmt, "char is not valid"),
8080
ErrorKind::InvalidTagEncoding(tag) => {
81-
write!(fmt, "tag for enum is not valid, found {}", tag)
81+
write!(fmt, "tag for enum is not valid, found {tag}")
8282
}
8383
ErrorKind::SequenceMustHaveLength => write!(fmt, "Bincode can only encode sequences and maps that have a knowable size ahead of time"),
8484
ErrorKind::SizeLimit => write!(fmt, "the size limit has been reached"),

float-pigment-consistent-bincode/tests/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ fn deserializing_errors() {
318318

319319
match *deserialize::<String>(&invalid_str[..]).unwrap_err() {
320320
ErrorKind::InvalidUtf8Encoding(_) => {}
321-
e => panic!("{:?}", e),
321+
e => panic!("{e:?}"),
322322
}
323323

324324
// Out-of-bounds variant
@@ -348,7 +348,7 @@ fn trailing_bytes() {
348348
.map_err(|e| *e)
349349
{
350350
Err(ErrorKind::Custom(_)) => {}
351-
other => panic!("Expecting TrailingBytes, got {:?}", other),
351+
other => panic!("Expecting TrailingBytes, got {other:?}"),
352352
}
353353
}
354354

@@ -590,7 +590,7 @@ fn test_slicebox_serialize() {
590590
let slice = [1u32, 2, 3, 4, 5];
591591
let serialized = serialize(&Cow::Borrowed(&slice[..])).unwrap();
592592
#[cfg(debug_assertions)]
593-
println!("{:?}", serialized);
593+
println!("{serialized:?}");
594594
let deserialized: Cow<'static, Vec<u32>> = deserialize_from(&mut &serialized[..]).unwrap();
595595
{
596596
let sb: &[u32] = &deserialized;

float-pigment-css-macro/src/compatibility_check.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn file_creator(
2323
path_buffer.push(std::env::var("CARGO_MANIFEST_DIR").unwrap());
2424
path_buffer.push(Path::new(CACHE_ROOT));
2525
path_buffer.push(Path::new(folder));
26-
path_buffer.push(Path::new(&format!("{}.{}", name, extension)));
26+
path_buffer.push(Path::new(&format!("{name}.{extension}")));
2727
let mut options = OpenOptions::new();
2828
let file = options
2929
.read(true)
@@ -287,7 +287,7 @@ pub(crate) fn compare_enum_cache(
287287
}
288288
let enum_name = match mod_name {
289289
Some(n) => {
290-
format!("{}_{}", n, name)
290+
format!("{n}_{name}")
291291
}
292292
None => name,
293293
};
@@ -448,10 +448,7 @@ pub(crate) fn compare_enum_cache(
448448
let mut file = file_creator("enum", &enum_name, EXTENSION, true, true).unwrap();
449449
file.write_all(next_cache_toml.as_bytes())
450450
.unwrap_or_else(|_| {
451-
panic!(
452-
"[CompatibilityEnumCheck] {:?}.{:?}: write cache error",
453-
enum_name, EXTENSION
454-
)
451+
panic!("[CompatibilityEnumCheck] {enum_name:?}.{EXTENSION:?}: write cache error")
455452
});
456453
}
457454

@@ -501,7 +498,7 @@ pub(crate) fn compare_struct_cache(
501498
token,
502499
} = input;
503500
let struct_name = match mod_name {
504-
Some(n) => format!("{}_{}", n, name),
501+
Some(n) => format!("{n}_{name}"),
505502
None => name,
506503
};
507504
// open or create cache
@@ -539,8 +536,7 @@ pub(crate) fn compare_struct_cache(
539536
return Err(Error::new(
540537
Span::call_site(),
541538
format!(
542-
"[CompatibilityStructCheck: 2001] struct {:?}, cache_fields: {:?}, cur_fields: {:?}, idx: {:?}",
543-
struct_name, prev, next, idx
539+
"[CompatibilityStructCheck: 2001] struct {struct_name:?}, cache_fields: {prev:?}, cur_fields: {next:?}, idx: {idx:?}"
544540
)
545541
));
546542
}
@@ -553,8 +549,7 @@ pub(crate) fn compare_struct_cache(
553549
file.write_all(next_cache_toml.as_bytes())
554550
.unwrap_or_else(|_| {
555551
panic!(
556-
"[CompatibilityStructCheck] {:?}.{:?}: write cache error",
557-
struct_name, EXTENSION
552+
"[CompatibilityStructCheck] {struct_name:?}.{EXTENSION:?}: write cache error"
558553
)
559554
});
560555
}

float-pigment-css-macro/src/property_list.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ impl Parse for PropertyItem {
4949
s
5050
})
5151
.collect();
52-
let set_field_name = Ident::new(&format!("set_{}", field_name), enum_name.span());
53-
let ref_field_name = Ident::new(&format!("{}_ref", field_name), enum_name.span());
52+
let set_field_name = Ident::new(&format!("set_{field_name}"), enum_name.span());
53+
let ref_field_name = Ident::new(&format!("{field_name}_ref"), enum_name.span());
5454
#[cfg(debug_assertions)]
55-
let field_name_type = Ident::new(&format!("{}_type", field_name), enum_name.span());
55+
let field_name_type = Ident::new(&format!("{field_name}_type"), enum_name.span());
5656
let field_name = Ident::new(&field_name, enum_name.span());
5757
input.parse::<Token![:]>()?;
5858

@@ -530,8 +530,7 @@ impl ToTokens for PropertiesDefinition {
530530
} = item;
531531
while cur_index < *index {
532532
cur_index += 1;
533-
let invalid_ident =
534-
Ident::new(&format!("Invalid{:X}", cur_index), enum_name.span());
533+
let invalid_ident = Ident::new(&format!("Invalid{cur_index:X}"), enum_name.span());
535534
enum_fields.push(quote!(#[doc(hidden)] #[serde(rename = "_")] #invalid_ident));
536535
}
537536
cur_index += 1;

float-pigment-css-macro/src/resolve_font_size.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl ToTokens for DeriveResolveFontSize {
149149
.unnamed
150150
.iter()
151151
.enumerate()
152-
.map(|(i, x)| Ident::new(&format!("a{}", i), x.ty.span()))
152+
.map(|(i, x)| Ident::new(&format!("a{i}"), x.ty.span()))
153153
.collect();
154154
let resolve_fn = find_resolve_fn_list(&x.unnamed)
155155
.into_iter()

float-pigment-css-macro/src/style_syntax.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -902,19 +902,19 @@ impl ToTokens for StyleSyntaxDefinition {
902902
let name = x.name.as_ref().unwrap();
903903
let non_standard = name.starts_with('-');
904904
let name_col = if non_standard {
905-
format!("*`{}`*", name)
905+
format!("*`{name}`*")
906906
} else {
907-
format!("`{}`", name)
907+
format!("`{name}`")
908908
};
909909
let mut doc_col = String::new();
910910
let mut options_col = vec![];
911911
if let StyleSyntaxValueItem::Assign(variant, v) = &x.value {
912-
doc_col = format!("[Property::{}]", variant);
912+
doc_col = format!("[Property::{variant}]");
913913
if let StyleSyntaxValueItem::Branch(branches) = &**v {
914914
for item in branches {
915915
if let StyleSyntaxValueItem::Convert(v, _) = item {
916916
if let StyleSyntaxValueItem::MatchIdent(s) = &**v {
917-
options_col.push(format!("`{}`", s));
917+
options_col.push(format!("`{s}`"));
918918
}
919919
}
920920
}

float-pigment-css-macro/src/value_type.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl Parse for PropertyValueType {
4545
let mut new_variants = parse_str::<ItemEnum>(s)?.variants;
4646
for i in new_variants.len()..PRESERVE_GLOBAL_VALUE_RANGE {
4747
let mut empty_slot = new_variants.last().unwrap().clone();
48-
empty_slot.ident = Ident::new(&format!("Invalid{:X}", i), empty_slot.ident.span());
48+
empty_slot.ident = Ident::new(&format!("Invalid{i:X}"), empty_slot.ident.span());
4949
empty_slot.attrs.push(parse_quote!(#[doc(hidden)]));
5050
new_variants.push(empty_slot);
5151
}
@@ -105,7 +105,7 @@ impl ToTokens for PropertyValueType {
105105
}
106106
}
107107
Fields::Unnamed(x) => {
108-
let names = x.unnamed.iter().enumerate().map(|(index, _)| Ident::new(&format!("_{}", index), variant_name.span())).collect::<Vec<_>>();
108+
let names = x.unnamed.iter().enumerate().map(|(index, _)| Ident::new(&format!("_{index}"), variant_name.span())).collect::<Vec<_>>();
109109
quote! {
110110
#original_type_name::#variant_name(#(#names),*) => #extra_type_name::#variant_name(#(#names),*),
111111
}
@@ -128,7 +128,7 @@ impl ToTokens for PropertyValueType {
128128
}
129129
}
130130
Fields::Unnamed(x) => {
131-
let names = x.unnamed.iter().enumerate().map(|(index, _)| Ident::new(&format!("_{}", index), variant_name.span())).collect::<Vec<_>>();
131+
let names = x.unnamed.iter().enumerate().map(|(index, _)| Ident::new(&format!("_{index}"), variant_name.span())).collect::<Vec<_>>();
132132
quote! {
133133
#extra_type_name::#variant_name(#(#names),*) => #original_type_name::#variant_name(#(#names),*),
134134
}

float-pigment-css/benches/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn create_random_selector() -> String {
1717
.take(30)
1818
.map(char::from)
1919
.collect();
20-
format!(".{}", random_string)
20+
format!(".{random_string}")
2121
}
2222

2323
fn random_rules_in_selectors(rules_times: i32, selector_times: i32) -> String {

float-pigment-css/src/ffi.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,7 @@ pub unsafe extern "C" fn style_sheet_import_index_add_bincode(
606606
let w = vec![Warning {
607607
kind: WarningKind::DeserializationFailed,
608608
message: format!(
609-
"failed to deserialize bincode formatted style sheet: {}",
610-
err
609+
"failed to deserialize bincode formatted style sheet: {err}"
611610
)
612611
.into(),
613612
start_line: 0,
@@ -1100,11 +1099,8 @@ pub unsafe extern "C" fn style_sheet_bincode_version(
11001099
let mut ss = StyleSheet::from_sheet(&sheet::CompiledStyleSheet::new());
11011100
if let StyleSheet::V1(ssv) = &mut ss {
11021101
ssv.version = Box::new(
1103-
format!(
1104-
"Failed to deserialize bincode formatted style sheet: {}",
1105-
err
1106-
)
1107-
.into(),
1102+
format!("Failed to deserialize bincode formatted style sheet: {err}")
1103+
.into(),
11081104
);
11091105
}
11101106
ss

0 commit comments

Comments
 (0)