diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93896e7..ea91ef1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,11 +23,11 @@ jobs: if: matrix.rust == 'nightly' msrv: - name: Rust 1.15.0 + name: Rust 1.31.0 runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: dtolnay/rust-toolchain@1.15.0 + - uses: dtolnay/rust-toolchain@1.31.0 - run: cargo build - run: cargo build --features small diff --git a/Cargo.toml b/Cargo.toml index 8af8867..856fe8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ repository = "https://github.com/dtolnay/ryu" documentation = "https://docs.rs/ryu" readme = "README.md" build = "build.rs" +edition = "2018" [features] # Use smaller lookup tables. Instead of storing every required power of diff --git a/README.md b/README.md index e990313..44ec366 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Build Status](https://img.shields.io/github/workflow/status/dtolnay/ryu/CI/master)](https://github.com/dtolnay/ryu/actions?query=branch%3Amaster) [![Latest Version](https://img.shields.io/crates/v/ryu.svg)](https://crates.io/crates/ryu) [![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/ryu) -[![Rustc Version 1.15+](https://img.shields.io/badge/rustc-1.15+-lightgray.svg)](https://blog.rust-lang.org/2017/02/02/Rust-1.15.html) +[![Rustc Version 1.31+](https://img.shields.io/badge/rustc-1.31+-lightgray.svg)](https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html) Pure Rust implementation of Ryū, an algorithm to quickly convert floating point numbers to decimal strings. @@ -15,7 +15,7 @@ under the creative commons CC-BY-SA license. This Rust implementation is a line-by-line port of Ulf Adams' implementation in C, [https://github.com/ulfjack/ryu][upstream]. -*Requirements: this crate supports any compiler version back to rustc 1.15; it +*Requirements: this crate supports any compiler version back to rustc 1.31; it uses nothing from the Rust standard library so is usable from no_std crates.* [paper]: https://dl.acm.org/citation.cfm?id=3192369 diff --git a/benches/bench.rs b/benches/bench.rs index 04d9bee..f7a0d90 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -2,7 +2,6 @@ #![feature(test)] -extern crate ryu; extern crate test; macro_rules! benches { @@ -12,8 +11,6 @@ macro_rules! benches { $( #[bench] fn $name(b: &mut Bencher) { - use ryu; - let mut buf = ryu::Buffer::new(); b.iter(move || { diff --git a/examples/upstream_benchmark.rs b/examples/upstream_benchmark.rs index 7b91265..437855b 100644 --- a/examples/upstream_benchmark.rs +++ b/examples/upstream_benchmark.rs @@ -1,8 +1,5 @@ // cargo run --example upstream_benchmark --release -extern crate rand; -extern crate ryu; - use rand::{Rng, SeedableRng}; const SAMPLES: usize = 10000; diff --git a/src/buffer/mod.rs b/src/buffer/mod.rs index d524de6..df21fe0 100644 --- a/src/buffer/mod.rs +++ b/src/buffer/mod.rs @@ -1,10 +1,7 @@ -use core::{mem, slice, str}; - +use crate::raw; #[cfg(maybe_uninit)] use core::mem::MaybeUninit; - -use raw; - +use core::{mem, slice, str}; #[cfg(feature = "no-panic")] use no_panic::no_panic; @@ -16,7 +13,7 @@ const NEG_INFINITY: &'static str = "-inf"; /// /// ## Example /// -/// ```edition2018 +/// ``` /// let mut buffer = ryu::Buffer::new(); /// let printed = buffer.format_finite(1.234); /// assert_eq!(printed, "1.234"); diff --git a/src/d2s.rs b/src/d2s.rs index cebef96..213860f 100644 --- a/src/d2s.rs +++ b/src/d2s.rs @@ -18,20 +18,17 @@ // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. -use core::ptr; - -#[cfg(maybe_uninit)] -use core::mem::MaybeUninit; - +use crate::common::*; +#[cfg(not(feature = "small"))] +use crate::d2s_full_table::*; +use crate::d2s_intrinsics::*; +#[cfg(feature = "small")] +use crate::d2s_small_table::*; #[cfg(not(maybe_uninit))] use core::mem; - -use common::*; -#[cfg(not(feature = "small"))] -use d2s_full_table::*; -use d2s_intrinsics::*; -#[cfg(feature = "small")] -use d2s_small_table::*; +#[cfg(maybe_uninit)] +use core::mem::MaybeUninit; +use core::ptr; pub const DOUBLE_MANTISSA_BITS: u32 = 52; pub const DOUBLE_EXPONENT_BITS: u32 = 11; diff --git a/src/d2s_small_table.rs b/src/d2s_small_table.rs index fc4a1a2..c6f0973 100644 --- a/src/d2s_small_table.rs +++ b/src/d2s_small_table.rs @@ -18,9 +18,9 @@ // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. -use common::*; +use crate::common::*; #[cfg(not(integer128))] -use d2s_intrinsics::*; +use crate::d2s_intrinsics::*; pub static DOUBLE_POW5_TABLE: [u64; 26] = [ 1, diff --git a/src/f2s.rs b/src/f2s.rs index 4ad50a1..0633e8e 100644 --- a/src/f2s.rs +++ b/src/f2s.rs @@ -18,7 +18,7 @@ // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. -use common::*; +use crate::common::*; pub const FLOAT_MANTISSA_BITS: u32 = 23; pub const FLOAT_EXPONENT_BITS: u32 = 8; diff --git a/src/lib.rs b/src/lib.rs index f7fddb2..8974ed7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,7 @@ //! //! # Example //! -//! ```edition2018 +//! ``` //! fn main() { //! let mut buffer = ryu::Buffer::new(); //! let printed = buffer.format(1.234); @@ -88,9 +88,6 @@ allow(cast_lossless, many_single_char_names, unreadable_literal,) )] -#[cfg(feature = "no-panic")] -extern crate no_panic; - mod buffer; mod common; mod d2s; @@ -103,9 +100,9 @@ mod digit_table; mod f2s; mod pretty; -pub use buffer::{Buffer, Float}; +pub use crate::buffer::{Buffer, Float}; /// Unsafe functions that mirror the API of the C implementation of Ryū. pub mod raw { - pub use pretty::{format32, format64}; + pub use crate::pretty::{format32, format64}; } diff --git a/src/pretty/exponent.rs b/src/pretty/exponent.rs index f10643f..84053d5 100644 --- a/src/pretty/exponent.rs +++ b/src/pretty/exponent.rs @@ -1,7 +1,6 @@ +use crate::digit_table::*; use core::ptr; -use digit_table::*; - #[cfg_attr(feature = "no-panic", inline)] pub unsafe fn write_exponent3(mut k: isize, mut result: *mut u8) -> usize { let sign = k < 0; diff --git a/src/pretty/mantissa.rs b/src/pretty/mantissa.rs index 4280232..e5fc202 100644 --- a/src/pretty/mantissa.rs +++ b/src/pretty/mantissa.rs @@ -1,7 +1,6 @@ +use crate::digit_table::*; use core::ptr; -use digit_table::*; - #[cfg_attr(feature = "no-panic", inline)] pub unsafe fn write_mantissa_long(mut output: u64, mut result: *mut u8) { if (output >> 32) != 0 { diff --git a/src/pretty/mod.rs b/src/pretty/mod.rs index 1e51343..5eed13c 100644 --- a/src/pretty/mod.rs +++ b/src/pretty/mod.rs @@ -1,15 +1,12 @@ mod exponent; mod mantissa; -use core::{mem, ptr}; - use self::exponent::*; use self::mantissa::*; -use common; -use d2s; -use d2s::*; -use f2s::*; - +use crate::common; +use crate::d2s::{self, *}; +use crate::f2s::*; +use core::{mem, ptr}; #[cfg(feature = "no-panic")] use no_panic::no_panic; @@ -37,7 +34,7 @@ use no_panic::no_panic; /// /// ## Example /// -/// ```edition2018 +/// ``` /// use std::{mem::MaybeUninit, slice, str}; /// /// let f = 1.234f64; @@ -144,7 +141,7 @@ pub unsafe fn format64(f: f64, result: *mut u8) -> usize { /// /// ## Example /// -/// ```edition2018 +/// ``` /// use std::{mem::MaybeUninit, slice, str}; /// /// let f = 1.234f32; diff --git a/tests/d2s_table_test.rs b/tests/d2s_table_test.rs index 8f27726..9e30e71 100644 --- a/tests/d2s_table_test.rs +++ b/tests/d2s_table_test.rs @@ -20,8 +20,6 @@ #![allow(dead_code)] -extern crate core; - #[path = "../src/common.rs"] mod common; diff --git a/tests/d2s_test.rs b/tests/d2s_test.rs index a4118be..32a7821 100644 --- a/tests/d2s_test.rs +++ b/tests/d2s_test.rs @@ -18,9 +18,6 @@ // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. -extern crate rand; -extern crate ryu; - #[macro_use] mod macros; diff --git a/tests/exhaustive.rs b/tests/exhaustive.rs index 5c36969..e97045e 100644 --- a/tests/exhaustive.rs +++ b/tests/exhaustive.rs @@ -1,8 +1,5 @@ #![cfg(exhaustive)] -extern crate num_cpus; -extern crate ryu; - use std::str; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; diff --git a/tests/f2s_test.rs b/tests/f2s_test.rs index e6aaf5b..57eba43 100644 --- a/tests/f2s_test.rs +++ b/tests/f2s_test.rs @@ -18,9 +18,6 @@ // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. -extern crate rand; -extern crate ryu; - #[macro_use] mod macros;