Skip to content

Commit d8e1112

Browse files
committed
Fix future clippy warnings
1 parent 527ce3a commit d8e1112

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ members = [
138138
version = "0.4.0"
139139
authors = ["RustPython Team"]
140140
edition = "2024"
141-
rust-version = "1.85.0"
141+
rust-version = "1.87.0"
142142
repository = "https://github.com/RustPython/RustPython"
143143
license = "MIT"
144144

stdlib/src/array.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ mod array {
851851
}
852852

853853
fn _from_bytes(&self, b: &[u8], itemsize: usize, vm: &VirtualMachine) -> PyResult<()> {
854-
if b.len() % itemsize != 0 {
854+
if !b.len().is_multiple_of(itemsize) {
855855
return Err(vm.new_value_error("bytes length not a multiple of item size"));
856856
}
857857
if b.len() / itemsize > 0 {
@@ -1473,7 +1473,7 @@ mod array {
14731473
type Error = u8;
14741474

14751475
fn try_from(code: u8) -> Result<Self, Self::Error> {
1476-
let big_endian = code % 2 != 0;
1476+
let big_endian = !code.is_multiple_of(2);
14771477
let signed = match code {
14781478
0 | 1 => code != 0,
14791479
2..=13 => (code - 2) % 4 >= 2,
@@ -1615,7 +1615,7 @@ mod array {
16151615
let mut array = check_type_code(args.typecode, vm)?;
16161616
let format = args.mformat_code;
16171617
let bytes = args.items.as_bytes();
1618-
if bytes.len() % format.item_size() != 0 {
1618+
if !bytes.len().is_multiple_of(format.item_size()) {
16191619
return Err(vm.new_value_error("bytes length not a multiple of item size"));
16201620
}
16211621
if MachineFormatCode::from_typecode(array.typecode()) == Some(format) {

stdlib/src/pystruct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pub(crate) mod _struct {
171171
vm,
172172
"cannot iteratively unpack with a struct of length 0".to_owned(),
173173
))
174-
} else if buffer.len() % format_spec.size != 0 {
174+
} else if !buffer.len().is_multiple_of(format_spec.size) {
175175
Err(new_struct_error(
176176
vm,
177177
format!(

vm/src/builtins/memory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ impl PyMemoryView {
743743
fn cast_to_1d(&self, format: PyStrRef, vm: &VirtualMachine) -> PyResult<Self> {
744744
let format_spec = Self::parse_format(format.as_str(), vm)?;
745745
let itemsize = format_spec.size();
746-
if self.desc.len % itemsize != 0 {
746+
if !self.desc.len.is_multiple_of(itemsize) {
747747
return Err(vm.new_type_error("memoryview: length is not a multiple of itemsize"));
748748
}
749749

wtf8/src/core_str_count.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn do_count_chars(s: &Wtf8) -> usize {
3535
// Check the properties of `CHUNK_SIZE` and `UNROLL_INNER` that are required
3636
// for correctness.
3737
const _: () = assert!(CHUNK_SIZE < 256);
38-
const _: () = assert!(CHUNK_SIZE % UNROLL_INNER == 0);
38+
const _: () = assert!(CHUNK_SIZE.is_multiple_of(UNROLL_INNER));
3939

4040
// SAFETY: transmuting `[u8]` to `[usize]` is safe except for size
4141
// differences which are handled by `align_to`.

0 commit comments

Comments
 (0)