Skip to content

Commit

Permalink
Fix compatibility with Rust 1.43
Browse files Browse the repository at this point in the history
  • Loading branch information
akubera committed Oct 27, 2024
1 parent f68a86f commit 3c58a3e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ fn main() {
let ac = autocfg::new();
ac.emit_rustc_version(1, 70);

// slice::fill
ac.emit_rustc_version(1, 50);

// Option::zip
ac.emit_rustc_version(1, 46);

Expand Down
14 changes: 13 additions & 1 deletion src/impl_fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ fn format_ascii_digits_no_integer(
digits_ascii_be.copy_within(..sig_digit_count, sig_digit_idx);

// clear copied values
digits_ascii_be[..sig_digit_count.min(sig_digit_idx)].fill(b'0');
fill_slice(&mut digits_ascii_be[..sig_digit_count.min(sig_digit_idx)], b'0');
} else {
debug_assert_eq!(sig_digit_count, 1);
}
Expand All @@ -378,6 +378,18 @@ fn format_ascii_digits_no_integer(
}
}

#[cfg(rust_1_50)]
fn fill_slice<T: Clone>(v: &mut [T], value: T) {
v.fill(value);
}

#[cfg(not(rust_1_50))]
fn fill_slice<T: Clone>(v: &mut [T], value: T) {
for i in v.iter_mut() {
*i = value.clone();
}
}


/// Format integer as {int}e+{exp}
///
Expand Down

0 comments on commit 3c58a3e

Please sign in to comment.