Skip to content

Commit 0eb37b2

Browse files
committed
clippy
1 parent 3133509 commit 0eb37b2

File tree

14 files changed

+30
-34
lines changed

14 files changed

+30
-34
lines changed

examples/advanced-appconfig-feature-flags/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ async fn function_handler<T: ConfigurationFetcher + Send + Sync>(
3535

3636
// Use the feature flag
3737
let msg = if config.spanish_response {
38-
format!("{}, in spanish.", quote)
38+
format!("{quote}, in spanish.")
3939
} else {
40-
format!("{}.", quote)
40+
format!("{quote}.")
4141
};
4242

4343
// Return `Response` (it will be serialized to JSON automatically by the runtime)

examples/advanced-sqs-partial-batch-failures/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ where
5555
D: DeserializeOwned,
5656
R: Future<Output = Result<(), Error>>,
5757
{
58-
run(service_fn(|e| batch_handler(|d| f(d), e))).await
58+
run(service_fn(|e| batch_handler(&f, e))).await
5959
}
6060

6161
/// Helper function to lift the user provided `f` function from message to batch of messages.
@@ -123,7 +123,7 @@ mod test {
123123
}
124124

125125
#[tokio::test]
126-
async fn test() -> () {
126+
async fn test() {
127127
let msg_to_fail: SqsMessageObj<serde_json::Value> = serde_json::from_str(
128128
r#"{
129129
"messageId": "1",

examples/basic-error-handling/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl std::fmt::Display for CustomError {
4343
/// Display the error struct as a JSON string
4444
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4545
let err_as_json = json!(self).to_string();
46-
write!(f, "{}", err_as_json)
46+
write!(f, "{err_as_json}")
4747
}
4848
}
4949

@@ -66,7 +66,7 @@ pub(crate) async fn func(event: LambdaEvent<Request>) -> Result<Response, Error>
6666
match event.event_type {
6767
EventType::SimpleError => {
6868
// generate a simple text message error using `simple_error` crate
69-
return Err(Box::new(simple_error::SimpleError::new("A simple error as requested!")));
69+
Err(Box::new(simple_error::SimpleError::new("A simple error as requested!")))
7070
}
7171
EventType::CustomError => {
7272
// generate a custom error using our own structure
@@ -75,7 +75,7 @@ pub(crate) async fn func(event: LambdaEvent<Request>) -> Result<Response, Error>
7575
req_id: ctx.request_id,
7676
msg: "A custom error as requested!".into(),
7777
};
78-
return Err(Box::new(cust_err));
78+
Err(Box::new(cust_err))
7979
}
8080
EventType::ExternalError => {
8181
// try to open a non-existent file to get an error and propagate it with `?`
@@ -94,7 +94,7 @@ pub(crate) async fn func(event: LambdaEvent<Request>) -> Result<Response, Error>
9494
msg: "OK".into(),
9595
};
9696

97-
return Ok(resp);
97+
Ok(resp)
9898
}
9999
}
100100
}

examples/basic-error-thiserror/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use lambda_runtime::{service_fn, Diagnostic, Error, LambdaEvent};
22
use serde::Deserialize;
3-
use thiserror;
43

54
#[derive(Deserialize)]
65
struct Request {}
@@ -21,7 +20,7 @@ impl From<ExecutionError> for Diagnostic {
2120
};
2221
Diagnostic {
2322
error_type: error_type.into(),
24-
error_message: error_message.into(),
23+
error_message,
2524
}
2625
}
2726
}

examples/basic-lambda-external-runtime/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn main() -> Result<(), io::Error> {
5353
my_runtime(move || future::block_on(app_runtime_task(lambda_rx.clone(), shutdown_tx.clone())));
5454

5555
// Block the main thread until a shutdown signal is received.
56-
future::block_on(shutdown_rx.recv()).map_err(|err| io::Error::new(io::ErrorKind::Other, format!("{:?}", err)))
56+
future::block_on(shutdown_rx.recv()).map_err(|err| io::Error::other(format!("{err:?}")))
5757
}
5858

5959
pub(crate) async fn my_handler(event: LambdaEvent<Request>) -> Result<Response, Error> {
@@ -63,7 +63,7 @@ pub(crate) async fn my_handler(event: LambdaEvent<Request>) -> Result<Response,
6363
// prepare the response
6464
let resp = Response {
6565
req_id: event.context.request_id,
66-
msg: format!("Command {} executed.", command),
66+
msg: format!("Command {command} executed."),
6767
};
6868

6969
// return `Response` (it will be serialized to JSON automatically by the runtime)

examples/basic-lambda/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub(crate) async fn my_handler(event: LambdaEvent<Request>) -> Result<Response,
3939
// prepare the response
4040
let resp = Response {
4141
req_id: event.context.request_id,
42-
msg: format!("Command {} executed.", command),
42+
msg: format!("Command {command} executed."),
4343
};
4444

4545
// return `Response` (it will be serialized to JSON automatically by the runtime)

examples/basic-s3-object-lambda-thumbnail/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ mod tests {
114114

115115
mock.expect_send_file()
116116
.withf(|r, t, by| {
117-
return r.eq("O_ROUTE") && t.eq("O_TOKEN") && by == "THUMBNAIL".as_bytes();
117+
r.eq("O_ROUTE") && t.eq("O_TOKEN") && by == "THUMBNAIL".as_bytes()
118118
})
119119
.returning(|_1, _2, _3| Ok("File sent.".to_string()));
120120

@@ -128,7 +128,7 @@ mod tests {
128128
}
129129

130130
fn get_s3_event() -> S3ObjectLambdaEvent {
131-
return S3ObjectLambdaEvent {
131+
S3ObjectLambdaEvent {
132132
x_amz_request_id: ("ID".to_string()),
133133
head_object_context: (Some(HeadObjectContext::default())),
134134
list_objects_context: (Some(ListObjectsContext::default())),
@@ -146,6 +146,6 @@ mod tests {
146146
supporting_access_point_arn: ("SAPRN".to_string()),
147147
payload: (json!(null)),
148148
}),
149-
};
149+
}
150150
}
151151
}

examples/basic-s3-thumbnail/src/main.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,22 @@ mod tests {
174174

175175
mock.expect_put_file()
176176
.withf(|bu, ke, by| {
177-
return bu.eq("test-bucket-thumbs") && ke.eq(key) && by.eq("THUMBNAIL".as_bytes());
177+
bu.eq("test-bucket-thumbs") && ke.eq(key) && by.eq("THUMBNAIL".as_bytes())
178178
})
179179
.return_const(Ok("Done".to_string()));
180180

181181
let payload = get_s3_event("ObjectCreated", bucket, key);
182182
let event = LambdaEvent { payload, context };
183183

184-
let result = function_handler(event, 10, &mock).await.unwrap();
184+
function_handler(event, 10, &mock).await.unwrap();
185185

186-
assert_eq!((), result);
186+
assert_eq!((), ());
187187
}
188188

189189
fn get_s3_event(event_name: &str, bucket_name: &str, object_key: &str) -> S3Event {
190-
return S3Event {
190+
S3Event {
191191
records: (vec![get_s3_event_record(event_name, bucket_name, object_key)]),
192-
};
192+
}
193193
}
194194

195195
fn get_s3_event_record(event_name: &str, bucket_name: &str, object_key: &str) -> S3EventRecord {
@@ -213,7 +213,7 @@ mod tests {
213213
}),
214214
};
215215

216-
return S3EventRecord {
216+
S3EventRecord {
217217
event_version: (Some(String::default())),
218218
event_source: (Some(String::default())),
219219
aws_region: (Some(String::default())),
@@ -227,6 +227,6 @@ mod tests {
227227
}),
228228
response_elements: (HashMap::new()),
229229
s3: (s3_entity),
230-
};
230+
}
231231
}
232232
}

examples/basic-s3-thumbnail/src/s3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl PutFile for S3Client {
4343
let result = self.put_object().bucket(bucket).key(key).body(bytes).send().await;
4444

4545
match result {
46-
Ok(_) => Ok(format!("Uploaded a file with key {} into {}", key, bucket)),
46+
Ok(_) => Ok(format!("Uploaded a file with key {key} into {bucket}")),
4747
Err(err) => Err(err.into_service_error().meta().message().unwrap().to_string()),
4848
}
4949
}

examples/basic-sdk/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async fn my_handler<T: ListObjects>(event: LambdaEvent<Request>, client: &T) ->
5252
let objects_rsp = client.list_objects(&bucket).await?;
5353
let objects: Vec<_> = objects_rsp
5454
.contents()
55-
.into_iter()
55+
.iter()
5656
.filter_map(|o| o.key().map(|k| k.to_string()))
5757
.collect();
5858

0 commit comments

Comments
 (0)