Skip to content

Commit 6ed76b0

Browse files
bmc-msftdemoray
andauthored
address clippy issues (#664)
* address clippy issues * more clippy updates from 0.1.59 * more clippy updates * undo lifetime change suggested by clippy * format based on clippy changes * allow unnecessary_to_owned from services code Co-authored-by: Brian Caswell <bcaswell@microsoft.com>
1 parent 5296a91 commit 6ed76b0

File tree

15 files changed

+26
-31
lines changed

15 files changed

+26
-31
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
name: Services Tests
8181
runs-on: ubuntu-20.04
8282
env:
83-
RUSTFLAGS: -Dwarnings -Aunreachable-code -Aunused-assignments -Adead-code -Aclippy::new-without-default
83+
RUSTFLAGS: -Dwarnings -Aunreachable-code -Aunused-assignments -Adead-code -Aclippy::new-without-default -Aclippy::unnecessary_to_owned
8484
steps:
8585
- uses: actions/checkout@v2
8686
- uses: actions-rs/toolchain@v1

sdk/core/src/context.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ impl Context {
6666
{
6767
self.type_map
6868
.get(&TypeId::of::<E>())
69-
.map(|item| item.downcast_ref())
70-
.flatten()
69+
.and_then(|item| item.downcast_ref())
7170
}
7271

7372
/// Returns the number of entities in the type map.

sdk/data_cosmos/examples/stored_proc_00.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
3939
.await?;
4040

4141
println!("Response object:\n{:#?}", ret);
42-
println!("Response as JSON:\n{}", ret.payload.to_string());
42+
println!("Response as JSON:\n{}", ret.payload);
4343

4444
Ok(())
4545
}

sdk/data_cosmos/examples/stored_proc_01.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
7474
);
7575
println!(
7676
"Response as JSON:\n{}",
77-
execute_stored_procedure_response.payload.to_string()
77+
execute_stored_procedure_response.payload
7878
);
7979

8080
let delete_stored_procedure_response = stored_procedure_client

sdk/security_keyvault/src/key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ impl<'a, T: TokenCredential> KeyClient<'a, T> {
468468
let mut request_body = Map::new();
469469
request_body.insert(
470470
"value".to_owned(),
471-
Value::String(base64::encode(decrypt_parameters.ciphertext.to_owned())),
471+
Value::String(base64::encode(&decrypt_parameters.ciphertext)),
472472
);
473473

474474
let algorithm = match decrypt_parameters.decrypt_parameters_encryption {

sdk/storage_blobs/src/delete_snapshot_method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl AddAsHeader for DeleteSnapshotsMethod {
1414
) -> Result<(), azure_core::HttpHeaderError> {
1515
request.headers_mut().append(
1616
azure_core::headers::DELETE_SNAPSHOTS,
17-
http::header::HeaderValue::from_str(&self.to_string())?,
17+
http::header::HeaderValue::from_str(self.as_ref())?,
1818
);
1919

2020
Ok(())

sdk/storage_blobs/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl AddAsHeader for RehydratePriority {
8282
) -> std::result::Result<(), azure_core::HttpHeaderError> {
8383
request.headers_mut().append(
8484
headers::REHYDRATE_PRIORITY,
85-
http::header::HeaderValue::from_str(&self.to_string())?,
85+
http::header::HeaderValue::from_str(self.as_ref())?,
8686
);
8787

8888
Ok(())

sdk/storage_queues/examples/queue_create.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,22 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
5353
let response = queue.get_metadata().execute().await?;
5454
println!("response == {:#?}", response);
5555

56-
// create two queue stored access policies
57-
let mut queue_stored_acess_policies = Vec::new();
58-
queue_stored_acess_policies.push(
56+
// use two queue stored access policies
57+
let queue_stored_acess_policies = vec![
5958
QueueStoredAccessPolicy::new(
6059
"first_sap_read_process",
6160
Utc::now() - Duration::hours(1),
6261
Utc::now() + Duration::days(1),
6362
)
6463
.enable_read()
6564
.enable_process(),
66-
);
67-
queue_stored_acess_policies.push(
6865
QueueStoredAccessPolicy::new(
6966
"sap_admin",
7067
Utc::now() - chrono::Duration::hours(1),
7168
Utc::now() + chrono::Duration::hours(5),
7269
)
7370
.enable_all(),
74-
);
71+
];
7572

7673
let response = queue
7774
.set_acl()

services/autorust/codegen/examples/multiple_versions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
1111
fn main() -> Result<()> {
1212
println!("CONTROL PLANE");
1313
check(&get_mgmt_readmes()?)?;
14-
println!("");
14+
println!();
1515
println!("DATA PLANE");
1616
check(&get_svc_readmes()?)?;
1717
Ok(())
@@ -32,7 +32,7 @@ fn check(readmes: &[SpecReadme]) -> Result<()> {
3232
for version in versions {
3333
println!(" {}", version);
3434
}
35-
tags = tags + 1;
35+
tags += 1;
3636
services.insert(readme.spec());
3737
}
3838
}
@@ -41,7 +41,7 @@ fn check(readmes: &[SpecReadme]) -> Result<()> {
4141
}
4242
}
4343
}
44-
println!("");
44+
println!();
4545
println!("{} tags", tags);
4646
println!("{} services:", services.len());
4747
for service in services {

services/autorust/codegen/src/codegen_models.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl SchemaGen {
114114
}
115115

116116
fn default(&self) -> Option<&str> {
117-
self.schema.common.default.as_ref().map(|v| v.as_str()).flatten()
117+
self.schema.common.default.as_ref().and_then(|v| v.as_str())
118118
}
119119

120120
/// If the type should implement Default

0 commit comments

Comments
 (0)