mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-09 14:19:22 +00:00
style: improve use of std api
- replace get(0) by first() lint message: accessing first element with `objs.get(0)` help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#get_first - use io::Error::other method available since Rust 1.87 lint message: this can be `std::io::Error::other(_)` help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#io_other_error - implement From<_> instead of Into<_> lint message: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true help: `impl From<Local> for Foreign` is allowed by the orphan rules, for more information see https://doc.rust-lang.org/reference/items/implementations.html#trait-implementation-coherence help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#from_over_into - use next_back instead of rev + next lint message: manual backwards iteration help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#manual_next_back - use saturating_sub instead of manual implement it lint message: manual arithmetic check found help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#implicit_saturating_sub - add Default implementation for Checksummer use derived Default ans use it in new, as new set all value to None lint message: you should consider adding a `Default` implementation for `Checksummer` help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#new_without_default - use `any` instead of `find` + `is_some` lint message: called `is_some()` after searching an `Iterator` with `find` help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#search_is_some - replace `and_then` + `Some(_)` with `map` lint message: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#bind_instead_of_map - replace `skip_while` + `next` with `find` lint message: called `skip_while(<p>).next()` on an `Iterator` help: this is more succinctly expressed by calling `.find(!<p>)` instead help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#skip_while_next - use `matches!` instead of manual implementation lint message: match expression looks like `matches!` macro help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#match_like_matches_macro - use `keys` and `values methods insteads of iterating and ignoring either the keys or values. help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#iter_kv_map
This commit is contained in:
+2
-2
@@ -951,13 +951,13 @@ fn get_rpc_public_addr(config: &Config) -> Option<SocketAddr> {
|
||||
let filter_subnet: Option<ipnet::IpNet> = config
|
||||
.rpc_public_addr_subnet
|
||||
.as_ref()
|
||||
.and_then(|filter_subnet_str| match filter_subnet_str.parse::<ipnet::IpNet>() {
|
||||
.map(|filter_subnet_str| match filter_subnet_str.parse::<ipnet::IpNet>() {
|
||||
Ok(filter_subnet) => {
|
||||
let filter_subnet_trunc = filter_subnet.trunc();
|
||||
if filter_subnet_trunc != filter_subnet {
|
||||
warn!("`rpc_public_addr_subnet` changed after applying netmask, continuing with {}", filter_subnet.trunc());
|
||||
}
|
||||
Some(filter_subnet_trunc)
|
||||
filter_subnet_trunc
|
||||
}
|
||||
Err(e) => {
|
||||
panic!(
|
||||
|
||||
Reference in New Issue
Block a user