Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ members = [
version = "0.4.0"
authors = ["RustPython Team"]
edition = "2024"
rust-version = "1.85.0"
rust-version = "1.87.0"
repository = "https://github.com/RustPython/RustPython"
license = "MIT"

Expand Down
6 changes: 3 additions & 3 deletions stdlib/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ mod array {
}

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

fn try_from(code: u8) -> Result<Self, Self::Error> {
let big_endian = code % 2 != 0;
let big_endian = !code.is_multiple_of(2);
let signed = match code {
0 | 1 => code != 0,
2..=13 => (code - 2) % 4 >= 2,
Expand Down Expand Up @@ -1615,7 +1615,7 @@ mod array {
let mut array = check_type_code(args.typecode, vm)?;
let format = args.mformat_code;
let bytes = args.items.as_bytes();
if bytes.len() % format.item_size() != 0 {
if !bytes.len().is_multiple_of(format.item_size()) {
return Err(vm.new_value_error("bytes length not a multiple of item size"));
}
if MachineFormatCode::from_typecode(array.typecode()) == Some(format) {
Expand Down
2 changes: 1 addition & 1 deletion stdlib/src/pystruct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pub(crate) mod _struct {
vm,
"cannot iteratively unpack with a struct of length 0".to_owned(),
))
} else if buffer.len() % format_spec.size != 0 {
} else if !buffer.len().is_multiple_of(format_spec.size) {
Err(new_struct_error(
vm,
format!(
Expand Down
2 changes: 1 addition & 1 deletion vm/src/builtins/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ impl PyMemoryView {
fn cast_to_1d(&self, format: PyStrRef, vm: &VirtualMachine) -> PyResult<Self> {
let format_spec = Self::parse_format(format.as_str(), vm)?;
let itemsize = format_spec.size();
if self.desc.len % itemsize != 0 {
if !self.desc.len.is_multiple_of(itemsize) {
return Err(vm.new_type_error("memoryview: length is not a multiple of itemsize"));
}

Expand Down
2 changes: 1 addition & 1 deletion wtf8/src/core_str_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn do_count_chars(s: &Wtf8) -> usize {
// Check the properties of `CHUNK_SIZE` and `UNROLL_INNER` that are required
// for correctness.
const _: () = assert!(CHUNK_SIZE < 256);
const _: () = assert!(CHUNK_SIZE % UNROLL_INNER == 0);
const _: () = assert!(CHUNK_SIZE.is_multiple_of(UNROLL_INNER));

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