Skip to content

Commit

Permalink
chore: address clippy lints for Rust 1.86.0-beta
Browse files Browse the repository at this point in the history
Pull-Request: #5876.
  • Loading branch information
elenaf9 authored Feb 20, 2025
1 parent c34a77b commit 0d01a42
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion misc/quick-protobuf-codec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ mod tests {

let mut src = BytesMut::new();
src.extend_from_slice(encoded_length);
src.extend(std::iter::repeat(0).take(length));
src.extend(std::iter::repeat_n(0, length));
src
}

Expand Down
5 changes: 2 additions & 3 deletions protocols/autonat/src/v2/client/handler/dial_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{
collections::VecDeque,
convert::Infallible,
io,
iter::{once, repeat},
iter::{once, repeat_n},
task::{Context, Poll},
time::Duration,
};
Expand Down Expand Up @@ -326,8 +326,7 @@ where
{
let count_full = num_bytes / DATA_FIELD_LEN_UPPER_BOUND;
let partial_len = num_bytes % DATA_FIELD_LEN_UPPER_BOUND;
for req in repeat(DATA_FIELD_LEN_UPPER_BOUND)
.take(count_full)
for req in repeat_n(DATA_FIELD_LEN_UPPER_BOUND, count_full)
.chain(once(partial_len))
.filter(|e| *e > 0)
.map(|data_count| {
Expand Down
1 change: 1 addition & 0 deletions protocols/kad/src/kbucket/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#![allow(clippy::manual_div_ceil)]

use std::{
borrow::Borrow,
Expand Down
4 changes: 2 additions & 2 deletions protocols/kad/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub use record::{store, Key as RecordKey, ProviderRecord, Record};
/// DHT should agree on the choices made for (1) and (2).
///
/// The current value is `20`.
pub const K_VALUE: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(20) };
pub const K_VALUE: NonZeroUsize = NonZeroUsize::new(20).unwrap();

/// The `α` parameter of the Kademlia specification.
///
Expand All @@ -98,7 +98,7 @@ pub const K_VALUE: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(20) };
/// locating the closest peers to a key.
///
/// The current value is `3`.
pub const ALPHA_VALUE: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(3) };
pub const ALPHA_VALUE: NonZeroUsize = NonZeroUsize::new(3).unwrap();

pub const PROTOCOL_NAME: StreamProtocol = protocol::DEFAULT_PROTO_NAME;

Expand Down
2 changes: 1 addition & 1 deletion transports/webrtc/src/tokio/udp_mux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ fn ufrag_from_stun_message(buffer: &[u8], local_ufrag: bool) -> Result<String, E
let res = if local_ufrag {
s.split(':').next()
} else {
s.split(':').last()
s.split(':').next_back()
};
match res {
Some(s) => Ok(s.to_owned()),
Expand Down

0 comments on commit 0d01a42

Please sign in to comment.