Skip to content

Commit a44659c

Browse files
committed
chore: clippy fixes on inline string formatting
1 parent 3c39be0 commit a44659c

File tree

6 files changed

+17
-18
lines changed

6 files changed

+17
-18
lines changed

lambda-events/src/custom_serde/codebuild_time.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ impl Visitor<'_> for TimeVisitor {
1414
type Value = DateTime<Utc>;
1515

1616
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
17-
write!(formatter, "valid codebuild time: {}", CODEBUILD_TIME_FORMAT)
17+
write!(formatter, "valid codebuild time: {CODEBUILD_TIME_FORMAT}")
1818
}
1919

2020
fn visit_str<E: DeError>(self, val: &str) -> Result<Self::Value, E> {
2121
NaiveDateTime::parse_from_str(val, CODEBUILD_TIME_FORMAT)
2222
.map(|naive| naive.and_utc())
23-
.map_err(|e| DeError::custom(format!("Parse error {} for {}", e, val)))
23+
.map_err(|e| DeError::custom(format!("Parse error {e} for {val}")))
2424
}
2525
}
2626

lambda-events/src/custom_serde/float_unix_epoch.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,23 @@ fn ne_timestamp<T: fmt::Display>(ts: T) -> SerdeError<T, u8> {
1414

1515
impl<V: fmt::Display, D: fmt::Display> fmt::Debug for SerdeError<V, D> {
1616
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17-
write!(f, "ChronoSerdeError({})", self)
17+
write!(f, "ChronoSerdeError({self})")
1818
}
1919
}
2020

2121
impl<V: fmt::Display, D: fmt::Display> fmt::Display for SerdeError<V, D> {
2222
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2323
match *self {
2424
SerdeError::NonExistent { ref timestamp } => {
25-
write!(f, "value is not a legal timestamp: {}", timestamp)
25+
write!(f, "value is not a legal timestamp: {timestamp}")
2626
}
2727
SerdeError::Ambiguous {
2828
ref timestamp,
2929
ref min,
3030
ref max,
3131
} => write!(
3232
f,
33-
"value is an ambiguous timestamp: {}, could be either of {}, {}",
34-
timestamp, min, max
33+
"value is an ambiguous timestamp: {timestamp}, could be either of {min}, {max}",
3534
),
3635
}
3736
}

lambda-events/src/encodings/time.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ where
125125
let whole_seconds = seconds + (milliseconds as i64 / 1000);
126126
let subsec_millis = milliseconds % 1000;
127127
if milliseconds > 0 {
128-
let combined = format!("{}.{:03}", whole_seconds, subsec_millis);
128+
let combined = format!("{whole_seconds}.{subsec_millis:03}");
129129
serializer.serialize_str(&combined)
130130
} else {
131131
serializer.serialize_str(&whole_seconds.to_string())
@@ -159,7 +159,7 @@ where
159159
{
160160
let seconds = f64::deserialize(deserializer)?;
161161
TimeDelta::try_seconds(seconds as i64)
162-
.ok_or_else(|| D::Error::custom(format!("invalid time delta seconds `{}`", seconds)))
162+
.ok_or_else(|| D::Error::custom(format!("invalid time delta seconds `{seconds}`")))
163163
}
164164

165165
fn serialize_duration_minutes<S>(duration: &TimeDelta, serializer: S) -> Result<S::Ok, S::Error>
@@ -177,7 +177,7 @@ where
177177
{
178178
let minutes = f64::deserialize(deserializer)?;
179179
TimeDelta::try_minutes(minutes as i64)
180-
.ok_or_else(|| D::Error::custom(format!("invalid time delta minutes `{}`", minutes)))
180+
.ok_or_else(|| D::Error::custom(format!("invalid time delta minutes `{minutes}`")))
181181
}
182182

183183
fn normalize_timestamp<'de, D>(deserializer: D) -> Result<(u64, u64), D::Error>
@@ -199,7 +199,7 @@ where
199199
};
200200

201201
// We need to do this due to floating point issues.
202-
let input_as_string = format!("{}", input);
202+
let input_as_string = input.to_string();
203203
let parts: Result<Vec<u64>, _> = input_as_string
204204
.split('.')
205205
.map(|x| x.parse::<u64>().map_err(DeError::custom))

lambda-events/src/event/cloudwatch_alarms/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ impl Serialize for CloudWatchAlarmStateReasonData {
224224
Self::Composite(m) => serde_json::to_string(m),
225225
Self::Generic(m) => serde_json::to_string(m),
226226
};
227-
let s = r.map_err(|e| SerError::custom(format!("failed to serialize struct as string {}", e)))?;
227+
let s = r.map_err(|e| SerError::custom(format!("failed to serialize struct as string {e}")))?;
228228

229229
serializer.serialize_str(&s)
230230
}

lambda-events/src/event/dynamodb/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl fmt::Display for StreamViewType {
2727
StreamViewType::NewAndOldImages => "NEW_AND_OLD_IMAGES",
2828
StreamViewType::KeysOnly => "KEYS_ONLY",
2929
};
30-
write!(f, "{}", val)
30+
write!(f, "{val}")
3131
}
3232
}
3333

@@ -48,7 +48,7 @@ impl fmt::Display for StreamStatus {
4848
StreamStatus::Disabling => "DISABLING",
4949
StreamStatus::Disabled => "DISABLED",
5050
};
51-
write!(f, "{}", val)
51+
write!(f, "{val}")
5252
}
5353
}
5454

@@ -69,7 +69,7 @@ impl fmt::Display for SharedIteratorType {
6969
SharedIteratorType::AtSequenceNumber => "AT_SEQUENCE_NUMBER",
7070
SharedIteratorType::AfterSequenceNumber => "AFTER_SEQUENCE_NUMBER",
7171
};
72-
write!(f, "{}", val)
72+
write!(f, "{val}")
7373
}
7474
}
7575

@@ -88,7 +88,7 @@ impl fmt::Display for OperationType {
8888
OperationType::Modify => "MODIFY",
8989
OperationType::Remove => "REMOVE",
9090
};
91-
write!(f, "{}", val)
91+
write!(f, "{val}")
9292
}
9393
}
9494

@@ -105,7 +105,7 @@ impl fmt::Display for KeyType {
105105
KeyType::Hash => "HASH",
106106
KeyType::Range => "RANGE",
107107
};
108-
write!(f, "{}", val)
108+
write!(f, "{val}")
109109
}
110110
}
111111

lambda-extension/src/extension.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ where
259259
let io = TokioIo::new(tcp);
260260
tokio::task::spawn(async move {
261261
if let Err(err) = http1::Builder::new().serve_connection(io, make_service).await {
262-
println!("Error serving connection: {:?}", err);
262+
println!("Error serving connection: {err:?}");
263263
}
264264
});
265265
}
@@ -305,7 +305,7 @@ where
305305
let io = TokioIo::new(tcp);
306306
tokio::task::spawn(async move {
307307
if let Err(err) = http1::Builder::new().serve_connection(io, make_service).await {
308-
println!("Error serving connection: {:?}", err);
308+
println!("Error serving connection: {err:?}");
309309
}
310310
});
311311
}

0 commit comments

Comments
 (0)