Merge pull request #30 from dtolnay/edition

Update to 2018 edition
This commit is contained in:
David Tolnay
2020-05-29 21:55:44 -07:00
committed by GitHub
17 changed files with 31 additions and 61 deletions
+2 -2
View File
@@ -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
+1
View File
@@ -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
+2 -2
View File
@@ -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
-3
View File
@@ -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 || {
-3
View File
@@ -1,8 +1,5 @@
// cargo run --example upstream_benchmark --release
extern crate rand;
extern crate ryu;
use rand::{Rng, SeedableRng};
const SAMPLES: usize = 10000;
+3 -6
View File
@@ -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");
+9 -12
View File
@@ -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;
+2 -2
View File
@@ -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,
+1 -1
View File
@@ -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;
+3 -6
View File
@@ -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};
}
+1 -2
View File
@@ -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;
+1 -2
View File
@@ -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 {
+6 -9
View File
@@ -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;
-2
View File
@@ -20,8 +20,6 @@
#![allow(dead_code)]
extern crate core;
#[path = "../src/common.rs"]
mod common;
-3
View File
@@ -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;
-3
View File
@@ -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;
-3
View File
@@ -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;