Auto merge of #41437 - cuviper:remove-unstable-deprecated, r=alexcrichton
Remove items that are unstable and deprecated This removes unstable items that have been deprecated for more than one cycle. - Since 1.16.0, `#![feature(enumset)]` - All of `mod collections::enum_set` - Since 1.15.0, `#![feature(borrow_state)]` - `cell::BorrowState` - `RefCell::borrow_state()` - Since 1.15.0, `#![feature(is_unique)]` - `Rc::is_unique()` (made private like `Arc::is_unique()`) - Since 1.15.0, `#![feature(rc_would_unwrap)]` - `Rc::would_wrap()` - Since 1.13.0, `#![feature(binary_heap_extras)]` - `BinaryHeap::push_pop()` - `BinaryHeap::replace()` - Since 1.12.0, `#![feature(as_unsafe_cell)]` - `Cell::as_unsafe_cell()` - `RefCell::as_unsafe_cell()` - Since 1.12.0, `#![feature(map_entry_recover_keys)]` - `btree_map::OccupiedEntry::remove_pair()` - `hash_map::OccupiedEntry::remove_pair()` - Since 1.11.0, `#![feature(float_extras)]` - `Float::nan()` - `Float::infinity()` - `Float::neg_infinity()` - `Float::neg_zero()` - `Float::zero()` - `Float::one()` - `Float::integer_decode()` - `f32::integer_decode()` - `f32::ldexp()` - `f32::frexp()` - `f32::next_after()` - `f64::integer_decode()` - `f64::ldexp()` - `f64::frexp()` - `f64::next_after()` - Since 1.11.0, `#![feature(zero_one)]` - `num::Zero` - `num::One`
This commit is contained in:
commit
a94124488a
@ -102,11 +102,8 @@
|
||||
- [alloc_system](library-features/alloc-system.md)
|
||||
- [alloc](library-features/alloc.md)
|
||||
- [as_c_str](library-features/as-c-str.md)
|
||||
- [as_unsafe_cell](library-features/as-unsafe-cell.md)
|
||||
- [ascii_ctype](library-features/ascii-ctype.md)
|
||||
- [binary_heap_extras](library-features/binary-heap-extras.md)
|
||||
- [binary_heap_peek_mut_pop](library-features/binary-heap-peek-mut-pop.md)
|
||||
- [borrow_state](library-features/borrow-state.md)
|
||||
- [box_heap](library-features/box-heap.md)
|
||||
- [c_void_variant](library-features/c-void-variant.md)
|
||||
- [char_escape_debug](library-features/char-escape-debug.md)
|
||||
@ -131,14 +128,12 @@
|
||||
- [derive_clone_copy](library-features/derive-clone-copy.md)
|
||||
- [derive_eq](library-features/derive-eq.md)
|
||||
- [discriminant_value](library-features/discriminant-value.md)
|
||||
- [enumset](library-features/enumset.md)
|
||||
- [error_type_id](library-features/error-type-id.md)
|
||||
- [exact_size_is_empty](library-features/exact-size-is-empty.md)
|
||||
- [fd](library-features/fd.md)
|
||||
- [fd_read](library-features/fd-read.md)
|
||||
- [fixed_size_array](library-features/fixed-size-array.md)
|
||||
- [float_bits_conv](library-features/float-bits-conv.md)
|
||||
- [float_extras](library-features/float-extras.md)
|
||||
- [flt2dec](library-features/flt2dec.md)
|
||||
- [fmt_flags_align](library-features/fmt-flags-align.md)
|
||||
- [fmt_internals](library-features/fmt-internals.md)
|
||||
@ -158,7 +153,6 @@
|
||||
- [io_error_internals](library-features/io-error-internals.md)
|
||||
- [io](library-features/io.md)
|
||||
- [ip](library-features/ip.md)
|
||||
- [is_unique](library-features/is-unique.md)
|
||||
- [iter_rfind](library-features/iter-rfind.md)
|
||||
- [libstd_io_internals](library-features/libstd-io-internals.md)
|
||||
- [libstd_sys_internals](library-features/libstd-sys-internals.md)
|
||||
@ -166,7 +160,6 @@
|
||||
- [linked_list_extras](library-features/linked-list-extras.md)
|
||||
- [lookup_host](library-features/lookup-host.md)
|
||||
- [manually_drop](library-features/manually-drop.md)
|
||||
- [map_entry_recover_keys](library-features/map-entry-recover-keys.md)
|
||||
- [mpsc_select](library-features/mpsc-select.md)
|
||||
- [n16](library-features/n16.md)
|
||||
- [never_type_impls](library-features/never-type-impls.md)
|
||||
@ -189,7 +182,6 @@
|
||||
- [rand](library-features/rand.md)
|
||||
- [range_contains](library-features/range-contains.md)
|
||||
- [raw](library-features/raw.md)
|
||||
- [rc_would_unwrap](library-features/rc-would-unwrap.md)
|
||||
- [retain_hash_collection](library-features/retain-hash-collection.md)
|
||||
- [reverse_cmp_key](library-features/reverse-cmp-key.md)
|
||||
- [rt](library-features/rt.md)
|
||||
@ -225,5 +217,3 @@
|
||||
- [windows_handle](library-features/windows-handle.md)
|
||||
- [windows_net](library-features/windows-net.md)
|
||||
- [windows_stdio](library-features/windows-stdio.md)
|
||||
- [zero_one](library-features/zero-one.md)
|
||||
>>>>>> Add top level sections to the Unstable Book.
|
||||
|
@ -1,7 +0,0 @@
|
||||
# `as_unsafe_cell`
|
||||
|
||||
The tracking issue for this feature is: [#27708]
|
||||
|
||||
[#27708]: https://github.com/rust-lang/rust/issues/27708
|
||||
|
||||
------------------------
|
@ -1,7 +0,0 @@
|
||||
# `binary_heap_extras`
|
||||
|
||||
The tracking issue for this feature is: [#28147]
|
||||
|
||||
[#28147]: https://github.com/rust-lang/rust/issues/28147
|
||||
|
||||
------------------------
|
@ -1,7 +0,0 @@
|
||||
# `borrow_state`
|
||||
|
||||
The tracking issue for this feature is: [#27733]
|
||||
|
||||
[#27733]: https://github.com/rust-lang/rust/issues/27733
|
||||
|
||||
------------------------
|
@ -1,7 +0,0 @@
|
||||
# `enumset`
|
||||
|
||||
The tracking issue for this feature is: [#37966]
|
||||
|
||||
[#37966]: https://github.com/rust-lang/rust/issues/37966
|
||||
|
||||
------------------------
|
@ -1,7 +0,0 @@
|
||||
# `float_extras`
|
||||
|
||||
The tracking issue for this feature is: [#27752]
|
||||
|
||||
[#27752]: https://github.com/rust-lang/rust/issues/27752
|
||||
|
||||
------------------------
|
@ -1,7 +0,0 @@
|
||||
# `is_unique`
|
||||
|
||||
The tracking issue for this feature is: [#28356]
|
||||
|
||||
[#28356]: https://github.com/rust-lang/rust/issues/28356
|
||||
|
||||
------------------------
|
@ -1,5 +0,0 @@
|
||||
# `map_entry_recover_keys`
|
||||
|
||||
The tracking issue for this feature is: [#34285]
|
||||
|
||||
[#34285]: https://github.com/rust-lang/rust/issues/34285
|
@ -1,5 +0,0 @@
|
||||
# `rc_would_unwrap`
|
||||
|
||||
The tracking issue for this feature is: [#28356]
|
||||
|
||||
[#28356]: https://github.com/rust-lang/rust/issues/28356
|
@ -1,7 +0,0 @@
|
||||
# `zero_one`
|
||||
|
||||
The tracking issue for this feature is: [#27739]
|
||||
|
||||
[#27739]: https://github.com/rust-lang/rust/issues/27739
|
||||
|
||||
------------------------
|
@ -340,19 +340,6 @@ impl<T> Rc<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks whether [`Rc::try_unwrap`][try_unwrap] would return
|
||||
/// [`Ok`].
|
||||
///
|
||||
/// [try_unwrap]: struct.Rc.html#method.try_unwrap
|
||||
/// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok
|
||||
#[unstable(feature = "rc_would_unwrap",
|
||||
reason = "just added for niche usecase",
|
||||
issue = "28356")]
|
||||
#[rustc_deprecated(since = "1.15.0", reason = "too niche; use `strong_count` instead")]
|
||||
pub fn would_unwrap(this: &Self) -> bool {
|
||||
Rc::strong_count(&this) == 1
|
||||
}
|
||||
|
||||
/// Consumes the `Rc`, returning the wrapped pointer.
|
||||
///
|
||||
/// To avoid a memory leak the pointer must be converted back to an `Rc` using
|
||||
@ -532,11 +519,7 @@ impl<T: ?Sized> Rc<T> {
|
||||
///
|
||||
/// [weak]: struct.Weak.html
|
||||
#[inline]
|
||||
#[unstable(feature = "is_unique", reason = "uniqueness has unclear meaning",
|
||||
issue = "28356")]
|
||||
#[rustc_deprecated(since = "1.15.0",
|
||||
reason = "too niche; use `strong_count` and `weak_count` instead")]
|
||||
pub fn is_unique(this: &Self) -> bool {
|
||||
fn is_unique(this: &Self) -> bool {
|
||||
Rc::weak_count(this) == 0 && Rc::strong_count(this) == 1
|
||||
}
|
||||
|
||||
|
@ -555,82 +555,6 @@ impl<T: Ord> BinaryHeap<T> {
|
||||
self.sift_up(0, old_len);
|
||||
}
|
||||
|
||||
/// Pushes an item onto the binary heap, then pops the greatest item off the queue in
|
||||
/// an optimized fashion.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(binary_heap_extras)]
|
||||
/// #![allow(deprecated)]
|
||||
///
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let mut heap = BinaryHeap::new();
|
||||
/// heap.push(1);
|
||||
/// heap.push(5);
|
||||
///
|
||||
/// assert_eq!(heap.push_pop(3), 5);
|
||||
/// assert_eq!(heap.push_pop(9), 9);
|
||||
/// assert_eq!(heap.len(), 2);
|
||||
/// assert_eq!(heap.peek(), Some(&3));
|
||||
/// ```
|
||||
#[unstable(feature = "binary_heap_extras",
|
||||
reason = "needs to be audited",
|
||||
issue = "28147")]
|
||||
#[rustc_deprecated(since = "1.13.0", reason = "use `peek_mut` instead")]
|
||||
pub fn push_pop(&mut self, mut item: T) -> T {
|
||||
match self.data.get_mut(0) {
|
||||
None => return item,
|
||||
Some(top) => {
|
||||
if *top > item {
|
||||
swap(&mut item, top);
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.sift_down(0);
|
||||
item
|
||||
}
|
||||
|
||||
/// Pops the greatest item off the binary heap, then pushes an item onto the queue in
|
||||
/// an optimized fashion. The push is done regardless of whether the binary heap
|
||||
/// was empty.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(binary_heap_extras)]
|
||||
/// #![allow(deprecated)]
|
||||
///
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let mut heap = BinaryHeap::new();
|
||||
///
|
||||
/// assert_eq!(heap.replace(1), None);
|
||||
/// assert_eq!(heap.replace(3), Some(1));
|
||||
/// assert_eq!(heap.len(), 1);
|
||||
/// assert_eq!(heap.peek(), Some(&3));
|
||||
/// ```
|
||||
#[unstable(feature = "binary_heap_extras",
|
||||
reason = "needs to be audited",
|
||||
issue = "28147")]
|
||||
#[rustc_deprecated(since = "1.13.0", reason = "use `peek_mut` instead")]
|
||||
pub fn replace(&mut self, mut item: T) -> Option<T> {
|
||||
if !self.is_empty() {
|
||||
swap(&mut item, &mut self.data[0]);
|
||||
self.sift_down(0);
|
||||
Some(item)
|
||||
} else {
|
||||
self.push(item);
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Consumes the `BinaryHeap` and returns the underlying vector
|
||||
/// in arbitrary order.
|
||||
///
|
||||
|
@ -2217,13 +2217,6 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
|
||||
self.handle.reborrow().into_kv().0
|
||||
}
|
||||
|
||||
/// Deprecated, renamed to `remove_entry`
|
||||
#[unstable(feature = "map_entry_recover_keys", issue = "34285")]
|
||||
#[rustc_deprecated(since = "1.12.0", reason = "renamed to `remove_entry`")]
|
||||
pub fn remove_pair(self) -> (K, V) {
|
||||
self.remove_entry()
|
||||
}
|
||||
|
||||
/// Take ownership of the key and value from the map.
|
||||
///
|
||||
/// # Examples
|
||||
|
@ -1,313 +0,0 @@
|
||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! A structure for holding a set of enum variants.
|
||||
//!
|
||||
//! This module defines a container which uses an efficient bit mask
|
||||
//! representation to hold C-like enum variants.
|
||||
|
||||
#![unstable(feature = "enumset",
|
||||
reason = "matches collection reform specification, \
|
||||
waiting for dust to settle",
|
||||
issue = "37966")]
|
||||
#![rustc_deprecated(since = "1.16.0", reason = "long since replaced")]
|
||||
#![allow(deprecated)]
|
||||
|
||||
use core::marker;
|
||||
use core::fmt;
|
||||
use core::iter::{FromIterator, FusedIterator};
|
||||
use core::ops::{Sub, BitOr, BitAnd, BitXor};
|
||||
|
||||
// FIXME(contentions): implement union family of methods? (general design may be
|
||||
// wrong here)
|
||||
|
||||
/// A specialized set implementation to use enum types.
|
||||
///
|
||||
/// It is a logic error for an item to be modified in such a way that the
|
||||
/// transformation of the item to or from a `usize`, as determined by the
|
||||
/// `CLike` trait, changes while the item is in the set. This is normally only
|
||||
/// possible through `Cell`, `RefCell`, global state, I/O, or unsafe code.
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct EnumSet<E> {
|
||||
// We must maintain the invariant that no bits are set
|
||||
// for which no variant exists
|
||||
bits: usize,
|
||||
marker: marker::PhantomData<E>,
|
||||
}
|
||||
|
||||
impl<E> Copy for EnumSet<E> {}
|
||||
|
||||
impl<E> Clone for EnumSet<E> {
|
||||
fn clone(&self) -> EnumSet<E> {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: CLike + fmt::Debug> fmt::Debug for EnumSet<E> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt.debug_set().entries(self).finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// An interface for casting C-like enum to usize and back.
|
||||
/// A typically implementation is as below.
|
||||
///
|
||||
/// ```{rust,ignore}
|
||||
/// #[repr(usize)]
|
||||
/// enum Foo {
|
||||
/// A, B, C
|
||||
/// }
|
||||
///
|
||||
/// impl CLike for Foo {
|
||||
/// fn to_usize(&self) -> usize {
|
||||
/// *self as usize
|
||||
/// }
|
||||
///
|
||||
/// fn from_usize(v: usize) -> Foo {
|
||||
/// unsafe { mem::transmute(v) }
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
pub trait CLike {
|
||||
/// Converts a C-like enum to a `usize`.
|
||||
fn to_usize(&self) -> usize;
|
||||
/// Converts a `usize` to a C-like enum.
|
||||
fn from_usize(usize) -> Self;
|
||||
}
|
||||
|
||||
fn bit<E: CLike>(e: &E) -> usize {
|
||||
use core::mem;
|
||||
let value = e.to_usize();
|
||||
let bits = mem::size_of::<usize>() * 8;
|
||||
assert!(value < bits,
|
||||
"EnumSet only supports up to {} variants.",
|
||||
bits - 1);
|
||||
1 << value
|
||||
}
|
||||
|
||||
impl<E: CLike> EnumSet<E> {
|
||||
/// Returns an empty `EnumSet`.
|
||||
pub fn new() -> EnumSet<E> {
|
||||
EnumSet {
|
||||
bits: 0,
|
||||
marker: marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the number of elements in the given `EnumSet`.
|
||||
pub fn len(&self) -> usize {
|
||||
self.bits.count_ones() as usize
|
||||
}
|
||||
|
||||
/// Returns `true` if the `EnumSet` is empty.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.bits == 0
|
||||
}
|
||||
|
||||
pub fn clear(&mut self) {
|
||||
self.bits = 0;
|
||||
}
|
||||
|
||||
/// Returns `false` if the `EnumSet` contains any enum of the given `EnumSet`.
|
||||
pub fn is_disjoint(&self, other: &EnumSet<E>) -> bool {
|
||||
(self.bits & other.bits) == 0
|
||||
}
|
||||
|
||||
/// Returns `true` if a given `EnumSet` is included in this `EnumSet`.
|
||||
pub fn is_superset(&self, other: &EnumSet<E>) -> bool {
|
||||
(self.bits & other.bits) == other.bits
|
||||
}
|
||||
|
||||
/// Returns `true` if this `EnumSet` is included in the given `EnumSet`.
|
||||
pub fn is_subset(&self, other: &EnumSet<E>) -> bool {
|
||||
other.is_superset(self)
|
||||
}
|
||||
|
||||
/// Returns the union of both `EnumSets`.
|
||||
pub fn union(&self, e: EnumSet<E>) -> EnumSet<E> {
|
||||
EnumSet {
|
||||
bits: self.bits | e.bits,
|
||||
marker: marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the intersection of both `EnumSets`.
|
||||
pub fn intersection(&self, e: EnumSet<E>) -> EnumSet<E> {
|
||||
EnumSet {
|
||||
bits: self.bits & e.bits,
|
||||
marker: marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
/// Adds an enum to the `EnumSet`, and returns `true` if it wasn't there before
|
||||
pub fn insert(&mut self, e: E) -> bool {
|
||||
let result = !self.contains(&e);
|
||||
self.bits |= bit(&e);
|
||||
result
|
||||
}
|
||||
|
||||
/// Removes an enum from the EnumSet
|
||||
pub fn remove(&mut self, e: &E) -> bool {
|
||||
let result = self.contains(e);
|
||||
self.bits &= !bit(e);
|
||||
result
|
||||
}
|
||||
|
||||
/// Returns `true` if an `EnumSet` contains a given enum.
|
||||
pub fn contains(&self, e: &E) -> bool {
|
||||
(self.bits & bit(e)) != 0
|
||||
}
|
||||
|
||||
/// Returns an iterator over an `EnumSet`.
|
||||
pub fn iter(&self) -> Iter<E> {
|
||||
Iter::new(self.bits)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: CLike> Sub for EnumSet<E> {
|
||||
type Output = EnumSet<E>;
|
||||
|
||||
fn sub(self, e: EnumSet<E>) -> EnumSet<E> {
|
||||
EnumSet {
|
||||
bits: self.bits & !e.bits,
|
||||
marker: marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: CLike> BitOr for EnumSet<E> {
|
||||
type Output = EnumSet<E>;
|
||||
|
||||
fn bitor(self, e: EnumSet<E>) -> EnumSet<E> {
|
||||
EnumSet {
|
||||
bits: self.bits | e.bits,
|
||||
marker: marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: CLike> BitAnd for EnumSet<E> {
|
||||
type Output = EnumSet<E>;
|
||||
|
||||
fn bitand(self, e: EnumSet<E>) -> EnumSet<E> {
|
||||
EnumSet {
|
||||
bits: self.bits & e.bits,
|
||||
marker: marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: CLike> BitXor for EnumSet<E> {
|
||||
type Output = EnumSet<E>;
|
||||
|
||||
fn bitxor(self, e: EnumSet<E>) -> EnumSet<E> {
|
||||
EnumSet {
|
||||
bits: self.bits ^ e.bits,
|
||||
marker: marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An iterator over an `EnumSet`
|
||||
pub struct Iter<E> {
|
||||
index: usize,
|
||||
bits: usize,
|
||||
marker: marker::PhantomData<E>,
|
||||
}
|
||||
|
||||
impl<E: fmt::Debug> fmt::Debug for Iter<E> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_tuple("Iter")
|
||||
.field(&self.index)
|
||||
.field(&self.bits)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
|
||||
impl<E> Clone for Iter<E> {
|
||||
fn clone(&self) -> Iter<E> {
|
||||
Iter {
|
||||
index: self.index,
|
||||
bits: self.bits,
|
||||
marker: marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: CLike> Iter<E> {
|
||||
fn new(bits: usize) -> Iter<E> {
|
||||
Iter {
|
||||
index: 0,
|
||||
bits: bits,
|
||||
marker: marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: CLike> Iterator for Iter<E> {
|
||||
type Item = E;
|
||||
|
||||
fn next(&mut self) -> Option<E> {
|
||||
if self.bits == 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
while (self.bits & 1) == 0 {
|
||||
self.index += 1;
|
||||
self.bits >>= 1;
|
||||
}
|
||||
let elem = CLike::from_usize(self.index);
|
||||
self.index += 1;
|
||||
self.bits >>= 1;
|
||||
Some(elem)
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
let exact = self.bits.count_ones() as usize;
|
||||
(exact, Some(exact))
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "fused", issue = "35602")]
|
||||
impl<E: CLike> FusedIterator for Iter<E> {}
|
||||
|
||||
impl<E: CLike> FromIterator<E> for EnumSet<E> {
|
||||
fn from_iter<I: IntoIterator<Item = E>>(iter: I) -> EnumSet<E> {
|
||||
let mut ret = EnumSet::new();
|
||||
ret.extend(iter);
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, E> IntoIterator for &'a EnumSet<E>
|
||||
where E: CLike
|
||||
{
|
||||
type Item = E;
|
||||
type IntoIter = Iter<E>;
|
||||
|
||||
fn into_iter(self) -> Iter<E> {
|
||||
self.iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: CLike> Extend<E> for EnumSet<E> {
|
||||
fn extend<I: IntoIterator<Item = E>>(&mut self, iter: I) {
|
||||
for element in iter {
|
||||
self.insert(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, E: 'a + CLike + Copy> Extend<&'a E> for EnumSet<E> {
|
||||
fn extend<I: IntoIterator<Item = &'a E>>(&mut self, iter: I) {
|
||||
self.extend(iter.into_iter().cloned());
|
||||
}
|
||||
}
|
@ -89,9 +89,6 @@ pub use btree_set::BTreeSet;
|
||||
#[doc(no_inline)]
|
||||
pub use linked_list::LinkedList;
|
||||
#[doc(no_inline)]
|
||||
#[allow(deprecated)]
|
||||
pub use enum_set::EnumSet;
|
||||
#[doc(no_inline)]
|
||||
pub use vec_deque::VecDeque;
|
||||
#[doc(no_inline)]
|
||||
pub use string::String;
|
||||
@ -107,7 +104,6 @@ mod macros;
|
||||
pub mod binary_heap;
|
||||
mod btree;
|
||||
pub mod borrow;
|
||||
pub mod enum_set;
|
||||
pub mod fmt;
|
||||
pub mod linked_list;
|
||||
pub mod range;
|
||||
|
@ -152,36 +152,6 @@ fn test_push_unique() {
|
||||
assert!(*heap.peek().unwrap() == box 103);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn test_push_pop() {
|
||||
let mut heap = BinaryHeap::from(vec![5, 5, 2, 1, 3]);
|
||||
assert_eq!(heap.len(), 5);
|
||||
assert_eq!(heap.push_pop(6), 6);
|
||||
assert_eq!(heap.len(), 5);
|
||||
assert_eq!(heap.push_pop(0), 5);
|
||||
assert_eq!(heap.len(), 5);
|
||||
assert_eq!(heap.push_pop(4), 5);
|
||||
assert_eq!(heap.len(), 5);
|
||||
assert_eq!(heap.push_pop(1), 4);
|
||||
assert_eq!(heap.len(), 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn test_replace() {
|
||||
let mut heap = BinaryHeap::from(vec![5, 5, 2, 1, 3]);
|
||||
assert_eq!(heap.len(), 5);
|
||||
assert_eq!(heap.replace(6).unwrap(), 5);
|
||||
assert_eq!(heap.len(), 5);
|
||||
assert_eq!(heap.replace(0).unwrap(), 6);
|
||||
assert_eq!(heap.len(), 5);
|
||||
assert_eq!(heap.replace(4).unwrap(), 5);
|
||||
assert_eq!(heap.len(), 5);
|
||||
assert_eq!(heap.replace(1).unwrap(), 4);
|
||||
assert_eq!(heap.len(), 5);
|
||||
}
|
||||
|
||||
fn check_to_vec(mut data: Vec<i32>) {
|
||||
let heap = BinaryHeap::from(data.clone());
|
||||
let mut v = heap.clone().into_vec();
|
||||
@ -227,13 +197,6 @@ fn test_empty_peek_mut() {
|
||||
assert!(empty.peek_mut().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn test_empty_replace() {
|
||||
let mut heap = BinaryHeap::new();
|
||||
assert!(heap.replace(5).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_iter() {
|
||||
let xs = vec![9, 8, 7, 6, 5, 4, 3, 2, 1];
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#![deny(warnings)]
|
||||
|
||||
#![feature(binary_heap_extras)]
|
||||
#![feature(binary_heap_peek_mut_pop)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(inclusive_range_syntax)]
|
||||
|
@ -310,26 +310,6 @@ impl<T> Cell<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a reference to the underlying `UnsafeCell`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(as_unsafe_cell)]
|
||||
///
|
||||
/// use std::cell::Cell;
|
||||
///
|
||||
/// let c = Cell::new(5);
|
||||
///
|
||||
/// let uc = c.as_unsafe_cell();
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "as_unsafe_cell", issue = "27708")]
|
||||
#[rustc_deprecated(since = "1.12.0", reason = "renamed to as_ptr")]
|
||||
pub fn as_unsafe_cell(&self) -> &UnsafeCell<T> {
|
||||
&self.value
|
||||
}
|
||||
|
||||
/// Returns a raw pointer to the underlying data in this cell.
|
||||
///
|
||||
/// # Examples
|
||||
@ -480,20 +460,6 @@ pub struct RefCell<T: ?Sized> {
|
||||
value: UnsafeCell<T>,
|
||||
}
|
||||
|
||||
/// An enumeration of values returned from the `state` method on a `RefCell<T>`.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
#[unstable(feature = "borrow_state", issue = "27733")]
|
||||
#[rustc_deprecated(since = "1.15.0", reason = "use `try_borrow` instead")]
|
||||
#[allow(deprecated)]
|
||||
pub enum BorrowState {
|
||||
/// The cell is currently being read, there is at least one active `borrow`.
|
||||
Reading,
|
||||
/// The cell is currently being written to, there is an active `borrow_mut`.
|
||||
Writing,
|
||||
/// There are no outstanding borrows on this cell.
|
||||
Unused,
|
||||
}
|
||||
|
||||
/// An error returned by [`RefCell::try_borrow`](struct.RefCell.html#method.try_borrow).
|
||||
#[stable(feature = "try_borrow", since = "1.13.0")]
|
||||
pub struct BorrowError {
|
||||
@ -582,38 +548,6 @@ impl<T> RefCell<T> {
|
||||
}
|
||||
|
||||
impl<T: ?Sized> RefCell<T> {
|
||||
/// Query the current state of this `RefCell`
|
||||
///
|
||||
/// The returned value can be dispatched on to determine if a call to
|
||||
/// `borrow` or `borrow_mut` would succeed.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(borrow_state)]
|
||||
///
|
||||
/// use std::cell::{BorrowState, RefCell};
|
||||
///
|
||||
/// let c = RefCell::new(5);
|
||||
///
|
||||
/// match c.borrow_state() {
|
||||
/// BorrowState::Writing => println!("Cannot be borrowed"),
|
||||
/// BorrowState::Reading => println!("Cannot be borrowed mutably"),
|
||||
/// BorrowState::Unused => println!("Can be borrowed (mutably as well)"),
|
||||
/// }
|
||||
/// ```
|
||||
#[unstable(feature = "borrow_state", issue = "27733")]
|
||||
#[rustc_deprecated(since = "1.15.0", reason = "use `try_borrow` instead")]
|
||||
#[allow(deprecated)]
|
||||
#[inline]
|
||||
pub fn borrow_state(&self) -> BorrowState {
|
||||
match self.borrow.get() {
|
||||
WRITING => BorrowState::Writing,
|
||||
UNUSED => BorrowState::Unused,
|
||||
_ => BorrowState::Reading,
|
||||
}
|
||||
}
|
||||
|
||||
/// Immutably borrows the wrapped value.
|
||||
///
|
||||
/// The borrow lasts until the returned `Ref` exits scope. Multiple
|
||||
@ -769,29 +703,6 @@ impl<T: ?Sized> RefCell<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a reference to the underlying `UnsafeCell`.
|
||||
///
|
||||
/// This can be used to circumvent `RefCell`'s safety checks.
|
||||
///
|
||||
/// This function is `unsafe` because `UnsafeCell`'s field is public.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(as_unsafe_cell)]
|
||||
///
|
||||
/// use std::cell::RefCell;
|
||||
///
|
||||
/// let c = RefCell::new(5);
|
||||
/// let c = unsafe { c.as_unsafe_cell() };
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "as_unsafe_cell", issue = "27708")]
|
||||
#[rustc_deprecated(since = "1.12.0", reason = "renamed to as_ptr")]
|
||||
pub unsafe fn as_unsafe_cell(&self) -> &UnsafeCell<T> {
|
||||
&self.value
|
||||
}
|
||||
|
||||
/// Returns a raw pointer to the underlying data in this cell.
|
||||
///
|
||||
/// # Examples
|
||||
|
@ -15,7 +15,6 @@
|
||||
// FIXME: #6220 Implement floating point formatting
|
||||
|
||||
use fmt;
|
||||
use num::Zero;
|
||||
use ops::{Div, Rem, Sub};
|
||||
use str;
|
||||
use slice;
|
||||
@ -23,8 +22,9 @@ use ptr;
|
||||
use mem;
|
||||
|
||||
#[doc(hidden)]
|
||||
trait Int: Zero + PartialEq + PartialOrd + Div<Output=Self> + Rem<Output=Self> +
|
||||
trait Int: PartialEq + PartialOrd + Div<Output=Self> + Rem<Output=Self> +
|
||||
Sub<Output=Self> + Copy {
|
||||
fn zero() -> Self;
|
||||
fn from_u8(u: u8) -> Self;
|
||||
fn to_u8(&self) -> u8;
|
||||
fn to_u16(&self) -> u16;
|
||||
@ -35,6 +35,7 @@ trait Int: Zero + PartialEq + PartialOrd + Div<Output=Self> + Rem<Output=Self> +
|
||||
|
||||
macro_rules! doit {
|
||||
($($t:ident)*) => ($(impl Int for $t {
|
||||
fn zero() -> $t { 0 }
|
||||
fn from_u8(u: u8) -> $t { u as $t }
|
||||
fn to_u8(&self) -> u8 { *self as u8 }
|
||||
fn to_u16(&self) -> u16 { *self as u16 }
|
||||
|
@ -63,11 +63,8 @@ pub trait RawFloat : Float + Copy + Debug + LowerExp
|
||||
const NAN: Self;
|
||||
const ZERO: Self;
|
||||
|
||||
// suffix of "2" because Float::integer_decode is deprecated
|
||||
#[allow(deprecated)]
|
||||
fn integer_decode2(self) -> (u64, i16, i8) {
|
||||
Float::integer_decode(self)
|
||||
}
|
||||
/// Returns the mantissa, exponent and sign as integers.
|
||||
fn integer_decode(self) -> (u64, i16, i8);
|
||||
|
||||
/// Get the raw binary representation of the float.
|
||||
fn transmute(self) -> u64;
|
||||
@ -160,6 +157,21 @@ impl RawFloat for f32 {
|
||||
const ZERO_CUTOFF: i64 = -48;
|
||||
other_constants!(f32);
|
||||
|
||||
/// Returns the mantissa, exponent and sign as integers.
|
||||
fn integer_decode(self) -> (u64, i16, i8) {
|
||||
let bits: u32 = unsafe { transmute(self) };
|
||||
let sign: i8 = if bits >> 31 == 0 { 1 } else { -1 };
|
||||
let mut exponent: i16 = ((bits >> 23) & 0xff) as i16;
|
||||
let mantissa = if exponent == 0 {
|
||||
(bits & 0x7fffff) << 1
|
||||
} else {
|
||||
(bits & 0x7fffff) | 0x800000
|
||||
};
|
||||
// Exponent bias + mantissa shift
|
||||
exponent -= 127 + 23;
|
||||
(mantissa as u64, exponent, sign)
|
||||
}
|
||||
|
||||
fn transmute(self) -> u64 {
|
||||
let bits: u32 = unsafe { transmute(self) };
|
||||
bits as u64
|
||||
@ -171,7 +183,7 @@ impl RawFloat for f32 {
|
||||
}
|
||||
|
||||
fn unpack(self) -> Unpacked {
|
||||
let (sig, exp, _sig) = self.integer_decode2();
|
||||
let (sig, exp, _sig) = self.integer_decode();
|
||||
Unpacked::new(sig, exp)
|
||||
}
|
||||
|
||||
@ -196,6 +208,21 @@ impl RawFloat for f64 {
|
||||
const ZERO_CUTOFF: i64 = -326;
|
||||
other_constants!(f64);
|
||||
|
||||
/// Returns the mantissa, exponent and sign as integers.
|
||||
fn integer_decode(self) -> (u64, i16, i8) {
|
||||
let bits: u64 = unsafe { transmute(self) };
|
||||
let sign: i8 = if bits >> 63 == 0 { 1 } else { -1 };
|
||||
let mut exponent: i16 = ((bits >> 52) & 0x7ff) as i16;
|
||||
let mantissa = if exponent == 0 {
|
||||
(bits & 0xfffffffffffff) << 1
|
||||
} else {
|
||||
(bits & 0xfffffffffffff) | 0x10000000000000
|
||||
};
|
||||
// Exponent bias + mantissa shift
|
||||
exponent -= 1023 + 52;
|
||||
(mantissa, exponent, sign)
|
||||
}
|
||||
|
||||
fn transmute(self) -> u64 {
|
||||
let bits: u64 = unsafe { transmute(self) };
|
||||
bits
|
||||
@ -206,7 +233,7 @@ impl RawFloat for f64 {
|
||||
}
|
||||
|
||||
fn unpack(self) -> Unpacked {
|
||||
let (sig, exp, _sig) = self.integer_decode2();
|
||||
let (sig, exp, _sig) = self.integer_decode();
|
||||
Unpacked::new(sig, exp)
|
||||
}
|
||||
|
||||
|
@ -143,36 +143,6 @@ pub mod consts {
|
||||
reason = "stable interface is via `impl f{32,64}` in later crates",
|
||||
issue = "32110")]
|
||||
impl Float for f32 {
|
||||
#[inline]
|
||||
fn nan() -> f32 {
|
||||
NAN
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn infinity() -> f32 {
|
||||
INFINITY
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn neg_infinity() -> f32 {
|
||||
NEG_INFINITY
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn zero() -> f32 {
|
||||
0.0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn neg_zero() -> f32 {
|
||||
-0.0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn one() -> f32 {
|
||||
1.0
|
||||
}
|
||||
|
||||
/// Returns `true` if the number is NaN.
|
||||
#[inline]
|
||||
fn is_nan(self) -> bool {
|
||||
@ -214,21 +184,6 @@ impl Float for f32 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the mantissa, exponent and sign as integers.
|
||||
fn integer_decode(self) -> (u64, i16, i8) {
|
||||
let bits: u32 = unsafe { mem::transmute(self) };
|
||||
let sign: i8 = if bits >> 31 == 0 { 1 } else { -1 };
|
||||
let mut exponent: i16 = ((bits >> 23) & 0xff) as i16;
|
||||
let mantissa = if exponent == 0 {
|
||||
(bits & 0x7fffff) << 1
|
||||
} else {
|
||||
(bits & 0x7fffff) | 0x800000
|
||||
};
|
||||
// Exponent bias + mantissa shift
|
||||
exponent -= 127 + 23;
|
||||
(mantissa as u64, exponent, sign)
|
||||
}
|
||||
|
||||
/// Computes the absolute value of `self`. Returns `Float::nan()` if the
|
||||
/// number is `Float::nan()`.
|
||||
#[inline]
|
||||
|
@ -143,36 +143,6 @@ pub mod consts {
|
||||
reason = "stable interface is via `impl f{32,64}` in later crates",
|
||||
issue = "32110")]
|
||||
impl Float for f64 {
|
||||
#[inline]
|
||||
fn nan() -> f64 {
|
||||
NAN
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn infinity() -> f64 {
|
||||
INFINITY
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn neg_infinity() -> f64 {
|
||||
NEG_INFINITY
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn zero() -> f64 {
|
||||
0.0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn neg_zero() -> f64 {
|
||||
-0.0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn one() -> f64 {
|
||||
1.0
|
||||
}
|
||||
|
||||
/// Returns `true` if the number is NaN.
|
||||
#[inline]
|
||||
fn is_nan(self) -> bool {
|
||||
@ -214,21 +184,6 @@ impl Float for f64 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the mantissa, exponent and sign as integers.
|
||||
fn integer_decode(self) -> (u64, i16, i8) {
|
||||
let bits: u64 = unsafe { mem::transmute(self) };
|
||||
let sign: i8 = if bits >> 63 == 0 { 1 } else { -1 };
|
||||
let mut exponent: i16 = ((bits >> 52) & 0x7ff) as i16;
|
||||
let mantissa = if exponent == 0 {
|
||||
(bits & 0xfffffffffffff) << 1
|
||||
} else {
|
||||
(bits & 0xfffffffffffff) | 0x10000000000000
|
||||
};
|
||||
// Exponent bias + mantissa shift
|
||||
exponent -= 1023 + 52;
|
||||
(mantissa, exponent, sign)
|
||||
}
|
||||
|
||||
/// Computes the absolute value of `self`. Returns `Float::nan()` if the
|
||||
/// number is `Float::nan()`.
|
||||
#[inline]
|
||||
|
@ -67,7 +67,7 @@ impl DecodableFloat for f64 {
|
||||
/// Returns a sign (true when negative) and `FullDecoded` value
|
||||
/// from given floating point number.
|
||||
pub fn decode<T: DecodableFloat>(v: T) -> (/*negative?*/ bool, FullDecoded) {
|
||||
let (mant, exp, sign) = v.integer_decode2();
|
||||
let (mant, exp, sign) = v.integer_decode();
|
||||
let even = (mant & 1) == 0;
|
||||
let decoded = match v.classify() {
|
||||
FpCategory::Nan => FullDecoded::Nan,
|
||||
@ -81,7 +81,7 @@ pub fn decode<T: DecodableFloat>(v: T) -> (/*negative?*/ bool, FullDecoded) {
|
||||
exp: exp, inclusive: even })
|
||||
}
|
||||
FpCategory::Normal => {
|
||||
let minnorm = <T as DecodableFloat>::min_pos_norm_value().integer_decode2();
|
||||
let minnorm = <T as DecodableFloat>::min_pos_norm_value().integer_decode();
|
||||
if mant == minnorm.0 {
|
||||
// neighbors: (maxmant, exp - 1) -- (minnormmant, exp) -- (minnormmant + 1, exp)
|
||||
// where maxmant = minnormmant * 2 - 1
|
||||
|
@ -96,78 +96,6 @@ pub mod dec2flt;
|
||||
pub mod bignum;
|
||||
pub mod diy_float;
|
||||
|
||||
/// Types that have a "zero" value.
|
||||
///
|
||||
/// This trait is intended for use in conjunction with `Add`, as an identity:
|
||||
/// `x + T::zero() == x`.
|
||||
#[unstable(feature = "zero_one",
|
||||
reason = "unsure of placement, wants to use associated constants",
|
||||
issue = "27739")]
|
||||
#[rustc_deprecated(since = "1.11.0", reason = "no longer used for \
|
||||
Iterator::sum")]
|
||||
pub trait Zero: Sized {
|
||||
/// The "zero" (usually, additive identity) for this type.
|
||||
fn zero() -> Self;
|
||||
}
|
||||
|
||||
/// Types that have a "one" value.
|
||||
///
|
||||
/// This trait is intended for use in conjunction with `Mul`, as an identity:
|
||||
/// `x * T::one() == x`.
|
||||
#[unstable(feature = "zero_one",
|
||||
reason = "unsure of placement, wants to use associated constants",
|
||||
issue = "27739")]
|
||||
#[rustc_deprecated(since = "1.11.0", reason = "no longer used for \
|
||||
Iterator::product")]
|
||||
pub trait One: Sized {
|
||||
/// The "one" (usually, multiplicative identity) for this type.
|
||||
fn one() -> Self;
|
||||
}
|
||||
|
||||
macro_rules! zero_one_impl {
|
||||
($($t:ty)*) => ($(
|
||||
#[unstable(feature = "zero_one",
|
||||
reason = "unsure of placement, wants to use associated constants",
|
||||
issue = "27739")]
|
||||
#[allow(deprecated)]
|
||||
impl Zero for $t {
|
||||
#[inline]
|
||||
fn zero() -> Self { 0 }
|
||||
}
|
||||
#[unstable(feature = "zero_one",
|
||||
reason = "unsure of placement, wants to use associated constants",
|
||||
issue = "27739")]
|
||||
#[allow(deprecated)]
|
||||
impl One for $t {
|
||||
#[inline]
|
||||
fn one() -> Self { 1 }
|
||||
}
|
||||
)*)
|
||||
}
|
||||
zero_one_impl! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
|
||||
|
||||
macro_rules! zero_one_impl_float {
|
||||
($($t:ty)*) => ($(
|
||||
#[unstable(feature = "zero_one",
|
||||
reason = "unsure of placement, wants to use associated constants",
|
||||
issue = "27739")]
|
||||
#[allow(deprecated)]
|
||||
impl Zero for $t {
|
||||
#[inline]
|
||||
fn zero() -> Self { 0.0 }
|
||||
}
|
||||
#[unstable(feature = "zero_one",
|
||||
reason = "unsure of placement, wants to use associated constants",
|
||||
issue = "27739")]
|
||||
#[allow(deprecated)]
|
||||
impl One for $t {
|
||||
#[inline]
|
||||
fn one() -> Self { 1.0 }
|
||||
}
|
||||
)*)
|
||||
}
|
||||
zero_one_impl_float! { f32 f64 }
|
||||
|
||||
macro_rules! checked_op {
|
||||
($U:ty, $op:path, $x:expr, $y:expr) => {{
|
||||
let (result, overflowed) = unsafe { $op($x as $U, $y as $U) };
|
||||
@ -2525,49 +2453,6 @@ pub enum FpCategory {
|
||||
reason = "stable interface is via `impl f{32,64}` in later crates",
|
||||
issue = "32110")]
|
||||
pub trait Float: Sized {
|
||||
/// Returns the NaN value.
|
||||
#[unstable(feature = "float_extras", reason = "needs removal",
|
||||
issue = "27752")]
|
||||
#[rustc_deprecated(since = "1.11.0",
|
||||
reason = "never really came to fruition and easily \
|
||||
implementable outside the standard library")]
|
||||
fn nan() -> Self;
|
||||
/// Returns the infinite value.
|
||||
#[unstable(feature = "float_extras", reason = "needs removal",
|
||||
issue = "27752")]
|
||||
#[rustc_deprecated(since = "1.11.0",
|
||||
reason = "never really came to fruition and easily \
|
||||
implementable outside the standard library")]
|
||||
fn infinity() -> Self;
|
||||
/// Returns the negative infinite value.
|
||||
#[unstable(feature = "float_extras", reason = "needs removal",
|
||||
issue = "27752")]
|
||||
#[rustc_deprecated(since = "1.11.0",
|
||||
reason = "never really came to fruition and easily \
|
||||
implementable outside the standard library")]
|
||||
fn neg_infinity() -> Self;
|
||||
/// Returns -0.0.
|
||||
#[unstable(feature = "float_extras", reason = "needs removal",
|
||||
issue = "27752")]
|
||||
#[rustc_deprecated(since = "1.11.0",
|
||||
reason = "never really came to fruition and easily \
|
||||
implementable outside the standard library")]
|
||||
fn neg_zero() -> Self;
|
||||
/// Returns 0.0.
|
||||
#[unstable(feature = "float_extras", reason = "needs removal",
|
||||
issue = "27752")]
|
||||
#[rustc_deprecated(since = "1.11.0",
|
||||
reason = "never really came to fruition and easily \
|
||||
implementable outside the standard library")]
|
||||
fn zero() -> Self;
|
||||
/// Returns 1.0.
|
||||
#[unstable(feature = "float_extras", reason = "needs removal",
|
||||
issue = "27752")]
|
||||
#[rustc_deprecated(since = "1.11.0",
|
||||
reason = "never really came to fruition and easily \
|
||||
implementable outside the standard library")]
|
||||
fn one() -> Self;
|
||||
|
||||
/// Returns `true` if this value is NaN and false otherwise.
|
||||
#[stable(feature = "core", since = "1.6.0")]
|
||||
fn is_nan(self) -> bool;
|
||||
@ -2585,14 +2470,6 @@ pub trait Float: Sized {
|
||||
#[stable(feature = "core", since = "1.6.0")]
|
||||
fn classify(self) -> FpCategory;
|
||||
|
||||
/// Returns the mantissa, exponent and sign as integers, respectively.
|
||||
#[unstable(feature = "float_extras", reason = "signature is undecided",
|
||||
issue = "27752")]
|
||||
#[rustc_deprecated(since = "1.11.0",
|
||||
reason = "never really came to fruition and easily \
|
||||
implementable outside the standard library")]
|
||||
fn integer_decode(self) -> (u64, i16, i8);
|
||||
|
||||
/// Computes the absolute value of `self`. Returns `Float::nan()` if the
|
||||
/// number is `Float::nan()`.
|
||||
#[stable(feature = "core", since = "1.6.0")]
|
||||
|
@ -8,23 +8,14 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::f32;
|
||||
use std::f64;
|
||||
use std::mem;
|
||||
use core::num::diy_float::Fp;
|
||||
use core::num::dec2flt::rawfp::{fp_to_float, prev_float, next_float, round_normal};
|
||||
use core::num::dec2flt::rawfp::RawFloat;
|
||||
|
||||
fn integer_decode(f: f64) -> (u64, i16, i8) {
|
||||
let bits: u64 = unsafe { mem::transmute(f) };
|
||||
let sign: i8 = if bits >> 63 == 0 { 1 } else { -1 };
|
||||
let mut exponent: i16 = ((bits >> 52) & 0x7ff) as i16;
|
||||
let mantissa = if exponent == 0 {
|
||||
(bits & 0xfffffffffffff) << 1
|
||||
} else {
|
||||
(bits & 0xfffffffffffff) | 0x10000000000000
|
||||
};
|
||||
// Exponent bias + mantissa shift
|
||||
exponent -= 1023 + 52;
|
||||
(mantissa, exponent, sign)
|
||||
RawFloat::integer_decode(f)
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -152,3 +143,35 @@ fn next_float_monotonic() {
|
||||
}
|
||||
assert!(x > 0.5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_f32_integer_decode() {
|
||||
assert_eq!(3.14159265359f32.integer_decode(), (13176795, -22, 1));
|
||||
assert_eq!((-8573.5918555f32).integer_decode(), (8779358, -10, -1));
|
||||
assert_eq!(2f32.powf(100.0).integer_decode(), (8388608, 77, 1));
|
||||
assert_eq!(0f32.integer_decode(), (0, -150, 1));
|
||||
assert_eq!((-0f32).integer_decode(), (0, -150, -1));
|
||||
assert_eq!(f32::INFINITY.integer_decode(), (8388608, 105, 1));
|
||||
assert_eq!(f32::NEG_INFINITY.integer_decode(), (8388608, 105, -1));
|
||||
|
||||
// Ignore the "sign" (quiet / signalling flag) of NAN.
|
||||
// It can vary between runtime operations and LLVM folding.
|
||||
let (nan_m, nan_e, _nan_s) = f32::NAN.integer_decode();
|
||||
assert_eq!((nan_m, nan_e), (12582912, 105));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_f64_integer_decode() {
|
||||
assert_eq!(3.14159265359f64.integer_decode(), (7074237752028906, -51, 1));
|
||||
assert_eq!((-8573.5918555f64).integer_decode(), (4713381968463931, -39, -1));
|
||||
assert_eq!(2f64.powf(100.0).integer_decode(), (4503599627370496, 48, 1));
|
||||
assert_eq!(0f64.integer_decode(), (0, -1075, 1));
|
||||
assert_eq!((-0f64).integer_decode(), (0, -1075, -1));
|
||||
assert_eq!(f64::INFINITY.integer_decode(), (4503599627370496, 972, 1));
|
||||
assert_eq!(f64::NEG_INFINITY.integer_decode(), (4503599627370496, 972, -1));
|
||||
|
||||
// Ignore the "sign" (quiet / signalling flag) of NAN.
|
||||
// It can vary between runtime operations and LLVM folding.
|
||||
let (nan_m, nan_e, _nan_s) = f64::NAN.integer_decode();
|
||||
assert_eq!((nan_m, nan_e), (6755399441055744, 972));
|
||||
}
|
||||
|
@ -2017,13 +2017,6 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> {
|
||||
self.elem.read().0
|
||||
}
|
||||
|
||||
/// Deprecated, renamed to `remove_entry`
|
||||
#[unstable(feature = "map_entry_recover_keys", issue = "34285")]
|
||||
#[rustc_deprecated(since = "1.12.0", reason = "renamed to `remove_entry`")]
|
||||
pub fn remove_pair(self) -> (K, V) {
|
||||
self.remove_entry()
|
||||
}
|
||||
|
||||
/// Take the ownership of the key and value from the map.
|
||||
///
|
||||
/// # Examples
|
||||
|
@ -22,8 +22,6 @@ use core::num;
|
||||
#[cfg(not(test))]
|
||||
use intrinsics;
|
||||
#[cfg(not(test))]
|
||||
use libc::c_int;
|
||||
#[cfg(not(test))]
|
||||
use num::FpCategory;
|
||||
|
||||
|
||||
@ -73,8 +71,6 @@ mod cmath {
|
||||
pub fn atan2f(a: c_float, b: c_float) -> c_float;
|
||||
pub fn atanf(n: c_float) -> c_float;
|
||||
pub fn coshf(n: c_float) -> c_float;
|
||||
pub fn frexpf(n: c_float, value: &mut c_int) -> c_float;
|
||||
pub fn ldexpf(x: c_float, n: c_int) -> c_float;
|
||||
pub fn sinhf(n: c_float) -> c_float;
|
||||
pub fn tanf(n: c_float) -> c_float;
|
||||
pub fn tanhf(n: c_float) -> c_float;
|
||||
@ -84,7 +80,7 @@ mod cmath {
|
||||
pub use self::shims::*;
|
||||
#[cfg(target_env = "msvc")]
|
||||
mod shims {
|
||||
use libc::{c_float, c_int};
|
||||
use libc::c_float;
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn acosf(n: c_float) -> c_float {
|
||||
@ -111,20 +107,6 @@ mod cmath {
|
||||
f64::cosh(n as f64) as c_float
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(deprecated)]
|
||||
pub unsafe fn frexpf(x: c_float, value: &mut c_int) -> c_float {
|
||||
let (a, b) = f64::frexp(x as f64);
|
||||
*value = b as c_int;
|
||||
a as c_float
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(deprecated)]
|
||||
pub unsafe fn ldexpf(x: c_float, n: c_int) -> c_float {
|
||||
f64::ldexp(x as f64, n as isize) as c_float
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn sinhf(n: c_float) -> c_float {
|
||||
f64::sinh(n as f64) as c_float
|
||||
@ -244,40 +226,6 @@ impl f32 {
|
||||
#[inline]
|
||||
pub fn classify(self) -> FpCategory { num::Float::classify(self) }
|
||||
|
||||
/// Returns the mantissa, base 2 exponent, and sign as integers, respectively.
|
||||
/// The original number can be recovered by `sign * mantissa * 2 ^ exponent`.
|
||||
/// The floating point encoding is documented in the [Reference][floating-point].
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(float_extras)]
|
||||
///
|
||||
/// use std::f32;
|
||||
///
|
||||
/// let num = 2.0f32;
|
||||
///
|
||||
/// // (8388608, -22, 1)
|
||||
/// let (mantissa, exponent, sign) = num.integer_decode();
|
||||
/// let sign_f = sign as f32;
|
||||
/// let mantissa_f = mantissa as f32;
|
||||
/// let exponent_f = num.powf(exponent as f32);
|
||||
///
|
||||
/// // 1 * 8388608 * 2^(-22) == 2
|
||||
/// let abs_difference = (sign_f * mantissa_f * exponent_f - num).abs();
|
||||
///
|
||||
/// assert!(abs_difference <= f32::EPSILON);
|
||||
/// ```
|
||||
/// [floating-point]: ../reference/types.html#machine-types
|
||||
#[unstable(feature = "float_extras", reason = "signature is undecided",
|
||||
issue = "27752")]
|
||||
#[rustc_deprecated(since = "1.11.0",
|
||||
reason = "never really came to fruition and easily \
|
||||
implementable outside the standard library")]
|
||||
#[inline]
|
||||
#[allow(deprecated)]
|
||||
pub fn integer_decode(self) -> (u64, i16, i8) {
|
||||
num::Float::integer_decode(self)
|
||||
}
|
||||
|
||||
/// Returns the largest integer less than or equal to a number.
|
||||
///
|
||||
/// ```
|
||||
@ -712,89 +660,6 @@ impl f32 {
|
||||
#[inline]
|
||||
pub fn to_radians(self) -> f32 { num::Float::to_radians(self) }
|
||||
|
||||
/// Constructs a floating point number of `x*2^exp`.
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(float_extras)]
|
||||
///
|
||||
/// use std::f32;
|
||||
/// // 3*2^2 - 12 == 0
|
||||
/// let abs_difference = (f32::ldexp(3.0, 2) - 12.0).abs();
|
||||
///
|
||||
/// assert!(abs_difference <= f32::EPSILON);
|
||||
/// ```
|
||||
#[unstable(feature = "float_extras",
|
||||
reason = "pending integer conventions",
|
||||
issue = "27752")]
|
||||
#[rustc_deprecated(since = "1.11.0",
|
||||
reason = "never really came to fruition and easily \
|
||||
implementable outside the standard library")]
|
||||
#[inline]
|
||||
pub fn ldexp(x: f32, exp: isize) -> f32 {
|
||||
unsafe { cmath::ldexpf(x, exp as c_int) }
|
||||
}
|
||||
|
||||
/// Breaks the number into a normalized fraction and a base-2 exponent,
|
||||
/// satisfying:
|
||||
///
|
||||
/// * `self = x * 2^exp`
|
||||
/// * `0.5 <= abs(x) < 1.0`
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(float_extras)]
|
||||
///
|
||||
/// use std::f32;
|
||||
///
|
||||
/// let x = 4.0f32;
|
||||
///
|
||||
/// // (1/2)*2^3 -> 1 * 8/2 -> 4.0
|
||||
/// let f = x.frexp();
|
||||
/// let abs_difference_0 = (f.0 - 0.5).abs();
|
||||
/// let abs_difference_1 = (f.1 as f32 - 3.0).abs();
|
||||
///
|
||||
/// assert!(abs_difference_0 <= f32::EPSILON);
|
||||
/// assert!(abs_difference_1 <= f32::EPSILON);
|
||||
/// ```
|
||||
#[unstable(feature = "float_extras",
|
||||
reason = "pending integer conventions",
|
||||
issue = "27752")]
|
||||
#[rustc_deprecated(since = "1.11.0",
|
||||
reason = "never really came to fruition and easily \
|
||||
implementable outside the standard library")]
|
||||
#[inline]
|
||||
pub fn frexp(self) -> (f32, isize) {
|
||||
unsafe {
|
||||
let mut exp = 0;
|
||||
let x = cmath::frexpf(self, &mut exp);
|
||||
(x, exp as isize)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the next representable floating-point value in the direction of
|
||||
/// `other`.
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(float_extras)]
|
||||
///
|
||||
/// use std::f32;
|
||||
///
|
||||
/// let x = 1.0f32;
|
||||
///
|
||||
/// let abs_diff = (x.next_after(2.0) - 1.00000011920928955078125_f32).abs();
|
||||
///
|
||||
/// assert!(abs_diff <= f32::EPSILON);
|
||||
/// ```
|
||||
#[unstable(feature = "float_extras",
|
||||
reason = "unsure about its place in the world",
|
||||
issue = "27752")]
|
||||
#[rustc_deprecated(since = "1.11.0",
|
||||
reason = "never really came to fruition and easily \
|
||||
implementable outside the standard library")]
|
||||
#[inline]
|
||||
pub fn next_after(self, other: f32) -> f32 {
|
||||
unsafe { cmath::nextafterf(self, other) }
|
||||
}
|
||||
|
||||
/// Returns the maximum of the two numbers.
|
||||
///
|
||||
/// ```
|
||||
@ -1462,23 +1327,6 @@ mod tests {
|
||||
assert_eq!(1e-38f32.classify(), Fp::Subnormal);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn test_integer_decode() {
|
||||
assert_eq!(3.14159265359f32.integer_decode(), (13176795, -22, 1));
|
||||
assert_eq!((-8573.5918555f32).integer_decode(), (8779358, -10, -1));
|
||||
assert_eq!(2f32.powf(100.0).integer_decode(), (8388608, 77, 1));
|
||||
assert_eq!(0f32.integer_decode(), (0, -150, 1));
|
||||
assert_eq!((-0f32).integer_decode(), (0, -150, -1));
|
||||
assert_eq!(INFINITY.integer_decode(), (8388608, 105, 1));
|
||||
assert_eq!(NEG_INFINITY.integer_decode(), (8388608, 105, -1));
|
||||
|
||||
// Ignore the "sign" (quiet / signalling flag) of NAN.
|
||||
// It can vary between runtime operations and LLVM folding.
|
||||
let (nan_m, nan_e, _nan_s) = NAN.integer_decode();
|
||||
assert_eq!((nan_m, nan_e), (12582912, 105));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_floor() {
|
||||
assert_approx_eq!(1.0f32.floor(), 1.0f32);
|
||||
@ -1790,58 +1638,6 @@ mod tests {
|
||||
assert_eq!(neg_inf.to_radians(), neg_inf);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn test_ldexp() {
|
||||
let f1 = 2.0f32.powi(-123);
|
||||
let f2 = 2.0f32.powi(-111);
|
||||
let f3 = 1.75 * 2.0f32.powi(-12);
|
||||
assert_eq!(f32::ldexp(1f32, -123), f1);
|
||||
assert_eq!(f32::ldexp(1f32, -111), f2);
|
||||
assert_eq!(f32::ldexp(1.75f32, -12), f3);
|
||||
|
||||
assert_eq!(f32::ldexp(0f32, -123), 0f32);
|
||||
assert_eq!(f32::ldexp(-0f32, -123), -0f32);
|
||||
|
||||
let inf: f32 = f32::INFINITY;
|
||||
let neg_inf: f32 = f32::NEG_INFINITY;
|
||||
let nan: f32 = f32::NAN;
|
||||
assert_eq!(f32::ldexp(inf, -123), inf);
|
||||
assert_eq!(f32::ldexp(neg_inf, -123), neg_inf);
|
||||
assert!(f32::ldexp(nan, -123).is_nan());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn test_frexp() {
|
||||
let f1 = 2.0f32.powi(-123);
|
||||
let f2 = 2.0f32.powi(-111);
|
||||
let f3 = 1.75 * 2.0f32.powi(-123);
|
||||
let (x1, exp1) = f1.frexp();
|
||||
let (x2, exp2) = f2.frexp();
|
||||
let (x3, exp3) = f3.frexp();
|
||||
assert_eq!((x1, exp1), (0.5f32, -122));
|
||||
assert_eq!((x2, exp2), (0.5f32, -110));
|
||||
assert_eq!((x3, exp3), (0.875f32, -122));
|
||||
assert_eq!(f32::ldexp(x1, exp1), f1);
|
||||
assert_eq!(f32::ldexp(x2, exp2), f2);
|
||||
assert_eq!(f32::ldexp(x3, exp3), f3);
|
||||
|
||||
assert_eq!(0f32.frexp(), (0f32, 0));
|
||||
assert_eq!((-0f32).frexp(), (-0f32, 0));
|
||||
}
|
||||
|
||||
#[test] #[cfg_attr(windows, ignore)] // FIXME #8755
|
||||
#[allow(deprecated)]
|
||||
fn test_frexp_nowin() {
|
||||
let inf: f32 = f32::INFINITY;
|
||||
let neg_inf: f32 = f32::NEG_INFINITY;
|
||||
let nan: f32 = f32::NAN;
|
||||
assert_eq!(match inf.frexp() { (x, _) => x }, inf);
|
||||
assert_eq!(match neg_inf.frexp() { (x, _) => x }, neg_inf);
|
||||
assert!(match nan.frexp() { (x, _) => x.is_nan() })
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_asinh() {
|
||||
assert_eq!(0.0f32.asinh(), 0.0f32);
|
||||
|
@ -22,8 +22,6 @@ use core::num;
|
||||
#[cfg(not(test))]
|
||||
use intrinsics;
|
||||
#[cfg(not(test))]
|
||||
use libc::c_int;
|
||||
#[cfg(not(test))]
|
||||
use num::FpCategory;
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -188,36 +186,6 @@ impl f64 {
|
||||
#[inline]
|
||||
pub fn classify(self) -> FpCategory { num::Float::classify(self) }
|
||||
|
||||
/// Returns the mantissa, base 2 exponent, and sign as integers, respectively.
|
||||
/// The original number can be recovered by `sign * mantissa * 2 ^ exponent`.
|
||||
/// The floating point encoding is documented in the [Reference][floating-point].
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(float_extras)]
|
||||
///
|
||||
/// let num = 2.0f64;
|
||||
///
|
||||
/// // (8388608, -22, 1)
|
||||
/// let (mantissa, exponent, sign) = num.integer_decode();
|
||||
/// let sign_f = sign as f64;
|
||||
/// let mantissa_f = mantissa as f64;
|
||||
/// let exponent_f = num.powf(exponent as f64);
|
||||
///
|
||||
/// // 1 * 8388608 * 2^(-22) == 2
|
||||
/// let abs_difference = (sign_f * mantissa_f * exponent_f - num).abs();
|
||||
///
|
||||
/// assert!(abs_difference < 1e-10);
|
||||
/// ```
|
||||
/// [floating-point]: ../reference/types.html#machine-types
|
||||
#[unstable(feature = "float_extras", reason = "signature is undecided",
|
||||
issue = "27752")]
|
||||
#[rustc_deprecated(since = "1.11.0",
|
||||
reason = "never really came to fruition and easily \
|
||||
implementable outside the standard library")]
|
||||
#[inline]
|
||||
#[allow(deprecated)]
|
||||
pub fn integer_decode(self) -> (u64, i16, i8) { num::Float::integer_decode(self) }
|
||||
|
||||
/// Returns the largest integer less than or equal to a number.
|
||||
///
|
||||
/// ```
|
||||
@ -606,84 +574,6 @@ impl f64 {
|
||||
#[inline]
|
||||
pub fn to_radians(self) -> f64 { num::Float::to_radians(self) }
|
||||
|
||||
/// Constructs a floating point number of `x*2^exp`.
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(float_extras)]
|
||||
///
|
||||
/// // 3*2^2 - 12 == 0
|
||||
/// let abs_difference = (f64::ldexp(3.0, 2) - 12.0).abs();
|
||||
///
|
||||
/// assert!(abs_difference < 1e-10);
|
||||
/// ```
|
||||
#[unstable(feature = "float_extras",
|
||||
reason = "pending integer conventions",
|
||||
issue = "27752")]
|
||||
#[rustc_deprecated(since = "1.11.0",
|
||||
reason = "never really came to fruition and easily \
|
||||
implementable outside the standard library")]
|
||||
#[inline]
|
||||
pub fn ldexp(x: f64, exp: isize) -> f64 {
|
||||
unsafe { cmath::ldexp(x, exp as c_int) }
|
||||
}
|
||||
|
||||
/// Breaks the number into a normalized fraction and a base-2 exponent,
|
||||
/// satisfying:
|
||||
///
|
||||
/// * `self = x * 2^exp`
|
||||
/// * `0.5 <= abs(x) < 1.0`
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(float_extras)]
|
||||
///
|
||||
/// let x = 4.0_f64;
|
||||
///
|
||||
/// // (1/2)*2^3 -> 1 * 8/2 -> 4.0
|
||||
/// let f = x.frexp();
|
||||
/// let abs_difference_0 = (f.0 - 0.5).abs();
|
||||
/// let abs_difference_1 = (f.1 as f64 - 3.0).abs();
|
||||
///
|
||||
/// assert!(abs_difference_0 < 1e-10);
|
||||
/// assert!(abs_difference_1 < 1e-10);
|
||||
/// ```
|
||||
#[unstable(feature = "float_extras",
|
||||
reason = "pending integer conventions",
|
||||
issue = "27752")]
|
||||
#[rustc_deprecated(since = "1.11.0",
|
||||
reason = "never really came to fruition and easily \
|
||||
implementable outside the standard library")]
|
||||
#[inline]
|
||||
pub fn frexp(self) -> (f64, isize) {
|
||||
unsafe {
|
||||
let mut exp = 0;
|
||||
let x = cmath::frexp(self, &mut exp);
|
||||
(x, exp as isize)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the next representable floating-point value in the direction of
|
||||
/// `other`.
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(float_extras)]
|
||||
///
|
||||
/// let x = 1.0f64;
|
||||
///
|
||||
/// let abs_diff = (x.next_after(2.0) - 1.0000000000000002220446049250313_f64).abs();
|
||||
///
|
||||
/// assert!(abs_diff < 1e-10);
|
||||
/// ```
|
||||
#[unstable(feature = "float_extras",
|
||||
reason = "unsure about its place in the world",
|
||||
issue = "27752")]
|
||||
#[rustc_deprecated(since = "1.11.0",
|
||||
reason = "never really came to fruition and easily \
|
||||
implementable outside the standard library")]
|
||||
#[inline]
|
||||
pub fn next_after(self, other: f64) -> f64 {
|
||||
unsafe { cmath::nextafter(self, other) }
|
||||
}
|
||||
|
||||
/// Returns the maximum of the two numbers.
|
||||
///
|
||||
/// ```
|
||||
@ -1353,23 +1243,6 @@ mod tests {
|
||||
assert_eq!(1e-308f64.classify(), Fp::Subnormal);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn test_integer_decode() {
|
||||
assert_eq!(3.14159265359f64.integer_decode(), (7074237752028906, -51, 1));
|
||||
assert_eq!((-8573.5918555f64).integer_decode(), (4713381968463931, -39, -1));
|
||||
assert_eq!(2f64.powf(100.0).integer_decode(), (4503599627370496, 48, 1));
|
||||
assert_eq!(0f64.integer_decode(), (0, -1075, 1));
|
||||
assert_eq!((-0f64).integer_decode(), (0, -1075, -1));
|
||||
assert_eq!(INFINITY.integer_decode(), (4503599627370496, 972, 1));
|
||||
assert_eq!(NEG_INFINITY.integer_decode(), (4503599627370496, 972, -1));
|
||||
|
||||
// Ignore the "sign" (quiet / signalling flag) of NAN.
|
||||
// It can vary between runtime operations and LLVM folding.
|
||||
let (nan_m, nan_e, _nan_s) = NAN.integer_decode();
|
||||
assert_eq!((nan_m, nan_e), (6755399441055744, 972));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_floor() {
|
||||
assert_approx_eq!(1.0f64.floor(), 1.0f64);
|
||||
@ -1681,58 +1554,6 @@ mod tests {
|
||||
assert_eq!(neg_inf.to_radians(), neg_inf);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn test_ldexp() {
|
||||
let f1 = 2.0f64.powi(-123);
|
||||
let f2 = 2.0f64.powi(-111);
|
||||
let f3 = 1.75 * 2.0f64.powi(-12);
|
||||
assert_eq!(f64::ldexp(1f64, -123), f1);
|
||||
assert_eq!(f64::ldexp(1f64, -111), f2);
|
||||
assert_eq!(f64::ldexp(1.75f64, -12), f3);
|
||||
|
||||
assert_eq!(f64::ldexp(0f64, -123), 0f64);
|
||||
assert_eq!(f64::ldexp(-0f64, -123), -0f64);
|
||||
|
||||
let inf: f64 = INFINITY;
|
||||
let neg_inf: f64 = NEG_INFINITY;
|
||||
let nan: f64 = NAN;
|
||||
assert_eq!(f64::ldexp(inf, -123), inf);
|
||||
assert_eq!(f64::ldexp(neg_inf, -123), neg_inf);
|
||||
assert!(f64::ldexp(nan, -123).is_nan());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn test_frexp() {
|
||||
let f1 = 2.0f64.powi(-123);
|
||||
let f2 = 2.0f64.powi(-111);
|
||||
let f3 = 1.75 * 2.0f64.powi(-123);
|
||||
let (x1, exp1) = f1.frexp();
|
||||
let (x2, exp2) = f2.frexp();
|
||||
let (x3, exp3) = f3.frexp();
|
||||
assert_eq!((x1, exp1), (0.5f64, -122));
|
||||
assert_eq!((x2, exp2), (0.5f64, -110));
|
||||
assert_eq!((x3, exp3), (0.875f64, -122));
|
||||
assert_eq!(f64::ldexp(x1, exp1), f1);
|
||||
assert_eq!(f64::ldexp(x2, exp2), f2);
|
||||
assert_eq!(f64::ldexp(x3, exp3), f3);
|
||||
|
||||
assert_eq!(0f64.frexp(), (0f64, 0));
|
||||
assert_eq!((-0f64).frexp(), (-0f64, 0));
|
||||
}
|
||||
|
||||
#[test] #[cfg_attr(windows, ignore)] // FIXME #8755
|
||||
#[allow(deprecated)]
|
||||
fn test_frexp_nowin() {
|
||||
let inf: f64 = INFINITY;
|
||||
let neg_inf: f64 = NEG_INFINITY;
|
||||
let nan: f64 = NAN;
|
||||
assert_eq!(match inf.frexp() { (x, _) => x }, inf);
|
||||
assert_eq!(match neg_inf.frexp() { (x, _) => x }, neg_inf);
|
||||
assert!(match nan.frexp() { (x, _) => x.is_nan() })
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_asinh() {
|
||||
assert_eq!(0.0f64.asinh(), 0.0f64);
|
||||
|
@ -248,7 +248,6 @@
|
||||
#![feature(allow_internal_unstable)]
|
||||
#![feature(asm)]
|
||||
#![feature(associated_consts)]
|
||||
#![feature(borrow_state)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(cfg_target_has_atomic)]
|
||||
#![feature(cfg_target_thread_local)]
|
||||
@ -263,7 +262,6 @@
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(dropck_eyepatch)]
|
||||
#![feature(exact_size_is_empty)]
|
||||
#![feature(float_extras)]
|
||||
#![feature(float_from_str_radix)]
|
||||
#![feature(fn_traits)]
|
||||
#![feature(fnbox)]
|
||||
@ -319,7 +317,6 @@
|
||||
#![feature(untagged_unions)]
|
||||
#![feature(unwind_attributes)]
|
||||
#![feature(vec_push_all)]
|
||||
#![feature(zero_one)]
|
||||
#![cfg_attr(test, feature(update_panic_count))]
|
||||
#![cfg_attr(stage0, feature(pub_restricted))]
|
||||
#![cfg_attr(test, feature(float_bits_conv))]
|
||||
|
@ -16,9 +16,6 @@
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[allow(deprecated)]
|
||||
pub use core::num::{Zero, One};
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError};
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
@ -9,11 +9,22 @@
|
||||
// except according to those terms.
|
||||
|
||||
// ignore-emscripten no threads support
|
||||
#![feature(rustc_attrs, zero_one)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
use std::num::Zero;
|
||||
use std::thread;
|
||||
|
||||
trait Int {
|
||||
fn zero() -> Self;
|
||||
fn one() -> Self;
|
||||
}
|
||||
macro_rules! doit {
|
||||
($($t:ident)*) => ($(impl Int for $t {
|
||||
fn zero() -> $t { 0 }
|
||||
fn one() -> $t { 1 }
|
||||
})*)
|
||||
}
|
||||
doit! { i8 i16 i32 i64 isize }
|
||||
|
||||
macro_rules! check {
|
||||
($($e:expr),*) => {
|
||||
$(assert!(thread::spawn({
|
||||
@ -24,21 +35,21 @@ macro_rules! check {
|
||||
|
||||
fn main() {
|
||||
check![
|
||||
isize::min_value() / -1,
|
||||
i8::min_value() / -1,
|
||||
i16::min_value() / -1,
|
||||
i32::min_value() / -1,
|
||||
i64::min_value() / -1,
|
||||
isize::min_value() / -isize::one(),
|
||||
i8::min_value() / -i8::one(),
|
||||
i16::min_value() / -i16::one(),
|
||||
i32::min_value() / -i32::one(),
|
||||
i64::min_value() / -i64::one(),
|
||||
1isize / isize::zero(),
|
||||
1i8 / i8::zero(),
|
||||
1i16 / i16::zero(),
|
||||
1i32 / i32::zero(),
|
||||
1i64 / i64::zero(),
|
||||
isize::min_value() % -1,
|
||||
i8::min_value() % -1,
|
||||
i16::min_value() % -1,
|
||||
i32::min_value() % -1,
|
||||
i64::min_value() % -1,
|
||||
isize::min_value() % -isize::one(),
|
||||
i8::min_value() % -i8::one(),
|
||||
i16::min_value() % -i16::one(),
|
||||
i32::min_value() % -i32::one(),
|
||||
i64::min_value() % -i64::one(),
|
||||
1isize % isize::zero(),
|
||||
1i8 % i8::zero(),
|
||||
1i16 % i16::zero(),
|
||||
|
@ -10,13 +10,12 @@
|
||||
|
||||
#![allow(warnings)]
|
||||
#![feature(collections)]
|
||||
#![feature(drain, enumset, collections_bound, btree_range, vecmap)]
|
||||
#![feature(drain, collections_bound, btree_range, vecmap)]
|
||||
|
||||
extern crate collections;
|
||||
|
||||
use collections::BinaryHeap;
|
||||
use collections::{BTreeMap, BTreeSet};
|
||||
use collections::EnumSet;
|
||||
use collections::LinkedList;
|
||||
use collections::String;
|
||||
use collections::Vec;
|
||||
@ -25,7 +24,6 @@ use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use collections::Bound::Included;
|
||||
use collections::enum_set::CLike;
|
||||
use std::mem;
|
||||
|
||||
fn is_sync<T>(_: T) where T: Sync {}
|
||||
@ -76,21 +74,6 @@ fn main() {
|
||||
|
||||
all_sync_send!(LinkedList::<usize>::new(), iter, iter_mut, into_iter);
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(usize)]
|
||||
#[allow(dead_code)]
|
||||
enum Foo { A, B, C }
|
||||
impl CLike for Foo {
|
||||
fn to_usize(&self) -> usize {
|
||||
*self as usize
|
||||
}
|
||||
|
||||
fn from_usize(v: usize) -> Foo {
|
||||
unsafe { mem::transmute(v) }
|
||||
}
|
||||
}
|
||||
all_sync_send!(EnumSet::<Foo>::new(), iter);
|
||||
|
||||
all_sync_send!(VecDeque::<usize>::new(), iter, iter_mut, into_iter);
|
||||
is_sync_send!(VecDeque::<usize>::new(), drain(..));
|
||||
|
||||
|
@ -8,12 +8,10 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(core_float)]
|
||||
#![feature(float_extras)]
|
||||
#![feature(untagged_unions)]
|
||||
|
||||
extern crate core;
|
||||
use core::num::Float;
|
||||
use core::f32;
|
||||
|
||||
union U {
|
||||
a: (u8, u8),
|
||||
@ -33,8 +31,8 @@ fn main() {
|
||||
assert_eq!(u.a, (2, 2));
|
||||
|
||||
let mut w = W { a: 0b0_11111111_00000000000000000000000 };
|
||||
assert_eq!(w.b, f32::infinity());
|
||||
w.b = f32::neg_infinity();
|
||||
assert_eq!(w.b, f32::INFINITY);
|
||||
w.b = f32::NEG_INFINITY;
|
||||
assert_eq!(w.a, 0b1_11111111_00000000000000000000000);
|
||||
}
|
||||
}
|
||||
|
@ -9,8 +9,6 @@
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
#![feature(binary_heap_extras)]
|
||||
|
||||
use std::collections::BinaryHeap;
|
||||
|
||||
fn make_pq() -> BinaryHeap<isize> {
|
||||
|
Loading…
Reference in New Issue
Block a user