mirror of https://github.com/rust-lang/rust.git
core is now compilable
This commit is contained in:
parent
e80c020445
commit
63e0ddbf1d
|
@ -106,7 +106,6 @@
|
|||
#![feature(coerce_unsized)]
|
||||
#![feature(const_align_of_val)]
|
||||
#![feature(const_box)]
|
||||
#![feature(const_convert)]
|
||||
#![feature(const_cow_is_borrowed)]
|
||||
#![feature(const_eval_select)]
|
||||
#![feature(const_maybe_uninit_as_mut_ptr)]
|
||||
|
@ -174,7 +173,6 @@
|
|||
#![feature(associated_type_bounds)]
|
||||
#![feature(c_unwind)]
|
||||
#![feature(cfg_sanitize)]
|
||||
#![feature(const_deref)]
|
||||
#![feature(const_mut_refs)]
|
||||
#![feature(const_precise_live_drops)]
|
||||
#![feature(const_ptr_write)]
|
||||
|
|
|
@ -231,9 +231,8 @@ impl Layout {
|
|||
/// Returns an error if the combination of `self.size()` and the given
|
||||
/// `align` violates the conditions listed in [`Layout::from_size_align`].
|
||||
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
|
||||
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
||||
#[inline]
|
||||
pub const fn align_to(&self, align: usize) -> Result<Self, LayoutError> {
|
||||
pub fn align_to(&self, align: usize) -> Result<Self, LayoutError> {
|
||||
Layout::from_size_align(self.size(), cmp::max(self.align(), align))
|
||||
}
|
||||
|
||||
|
@ -315,9 +314,8 @@ impl Layout {
|
|||
///
|
||||
/// On arithmetic overflow, returns `LayoutError`.
|
||||
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
|
||||
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
||||
#[inline]
|
||||
pub const fn repeat(&self, n: usize) -> Result<(Self, usize), LayoutError> {
|
||||
pub fn repeat(&self, n: usize) -> Result<(Self, usize), LayoutError> {
|
||||
// This cannot overflow. Quoting from the invariant of Layout:
|
||||
// > `size`, when rounded up to the nearest multiple of `align`,
|
||||
// > must not overflow isize (i.e., the rounded value must be
|
||||
|
@ -376,9 +374,8 @@ impl Layout {
|
|||
/// # assert_eq!(repr_c(&[u64, u32, u16, u32]), Ok((s, vec![0, 8, 12, 16])));
|
||||
/// ```
|
||||
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
|
||||
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
||||
#[inline]
|
||||
pub const fn extend(&self, next: Self) -> Result<(Self, usize), LayoutError> {
|
||||
pub fn extend(&self, next: Self) -> Result<(Self, usize), LayoutError> {
|
||||
let new_align = cmp::max(self.align, next.align);
|
||||
let pad = self.padding_needed_for(next.align());
|
||||
|
||||
|
@ -403,9 +400,8 @@ impl Layout {
|
|||
///
|
||||
/// On arithmetic overflow, returns `LayoutError`.
|
||||
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
|
||||
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
||||
#[inline]
|
||||
pub const fn repeat_packed(&self, n: usize) -> Result<Self, LayoutError> {
|
||||
pub fn repeat_packed(&self, n: usize) -> Result<Self, LayoutError> {
|
||||
let size = self.size().checked_mul(n).ok_or(LayoutError)?;
|
||||
// The safe constructor is called here to enforce the isize size limit.
|
||||
Layout::from_size_alignment(size, self.align)
|
||||
|
@ -418,9 +414,8 @@ impl Layout {
|
|||
///
|
||||
/// On arithmetic overflow, returns `LayoutError`.
|
||||
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
|
||||
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
||||
#[inline]
|
||||
pub const fn extend_packed(&self, next: Self) -> Result<Self, LayoutError> {
|
||||
pub fn extend_packed(&self, next: Self) -> Result<Self, LayoutError> {
|
||||
let new_size = self.size().checked_add(next.size()).ok_or(LayoutError)?;
|
||||
// The safe constructor is called here to enforce the isize size limit.
|
||||
Layout::from_size_alignment(new_size, self.align)
|
||||
|
|
|
@ -30,8 +30,7 @@ impl bool {
|
|||
/// ```
|
||||
#[stable(feature = "bool_to_option", since = "1.62.0")]
|
||||
#[inline]
|
||||
pub fn then_some<T>(self, t: T) -> Option<T>
|
||||
{
|
||||
pub fn then_some<T>(self, t: T) -> Option<T> {
|
||||
if self { Some(t) } else { None }
|
||||
}
|
||||
|
||||
|
@ -57,8 +56,7 @@ impl bool {
|
|||
/// ```
|
||||
#[stable(feature = "lazy_bool_to_option", since = "1.50.0")]
|
||||
#[inline]
|
||||
pub fn then<T, F: FnOnce() -> T>(self, f: F) -> Option<T>
|
||||
{
|
||||
pub fn then<T, F: FnOnce() -> T>(self, f: F) -> Option<T> {
|
||||
if self { Some(f()) } else { None }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,8 +126,7 @@ pub trait Clone: Sized {
|
|||
/// allocations.
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn clone_from(&mut self, source: &Self)
|
||||
{
|
||||
fn clone_from(&mut self, source: &Self) {
|
||||
*self = source.clone()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
mod bytewise;
|
||||
pub(crate) use bytewise::BytewiseEq;
|
||||
|
||||
use crate::marker::Destruct;
|
||||
|
||||
use self::Ordering::*;
|
||||
|
||||
/// Trait for equality comparisons.
|
||||
|
@ -1158,9 +1156,8 @@ pub macro PartialOrd($item:item) {
|
|||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
|
||||
#[cfg_attr(not(test), rustc_diagnostic_item = "cmp_min")]
|
||||
pub const fn min<T: Ord>(v1: T, v2: T) -> T {
|
||||
pub fn min<T: Ord>(v1: T, v2: T) -> T {
|
||||
v1.min(v2)
|
||||
}
|
||||
|
||||
|
@ -1179,8 +1176,7 @@ pub const fn min<T: Ord>(v1: T, v2: T) -> T {
|
|||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
|
||||
pub fn min_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T
|
||||
{
|
||||
pub fn min_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
|
||||
match compare(&v1, &v2) {
|
||||
Ordering::Less | Ordering::Equal => v1,
|
||||
Ordering::Greater => v2,
|
||||
|
@ -1202,8 +1198,7 @@ pub fn min_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T
|
|||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
|
||||
pub fn min_by_key<T, F:FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T
|
||||
{
|
||||
pub fn min_by_key<T, F: FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T {
|
||||
min_by(v1, v2, |v1, v2| f(v1).cmp(&f(v2)))
|
||||
}
|
||||
|
||||
|
@ -1244,8 +1239,7 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
|
|||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
|
||||
pub fn max_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T
|
||||
{
|
||||
pub fn max_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
|
||||
match compare(&v1, &v2) {
|
||||
Ordering::Less | Ordering::Equal => v2,
|
||||
Ordering::Greater => v1,
|
||||
|
@ -1267,14 +1261,8 @@ pub fn max_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T
|
|||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
|
||||
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
|
||||
pub const fn max_by_key<T, F: FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T
|
||||
where
|
||||
T: Destruct,
|
||||
F: Destruct,
|
||||
K: Destruct,
|
||||
{
|
||||
max_by(v1, v2, const |v1, v2| f(v1).cmp(&f(v2)))
|
||||
pub fn max_by_key<T, F: FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T {
|
||||
max_by(v1, v2, |v1, v2| f(v1).cmp(&f(v2)))
|
||||
}
|
||||
|
||||
// Implementation of PartialEq, Eq, PartialOrd and Ord for primitive types
|
||||
|
|
|
@ -324,14 +324,14 @@ impl CStr {
|
|||
/// assert_eq!(c_str.to_str().unwrap(), "AAAAAAAA");
|
||||
/// ```
|
||||
///
|
||||
#[rustc_allow_const_fn_unstable(const_slice_index)]
|
||||
#[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")]
|
||||
#[rustc_const_stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")]
|
||||
pub const fn from_bytes_until_nul(bytes: &[u8]) -> Result<&CStr, FromBytesUntilNulError> {
|
||||
let nul_pos = memchr::memchr(0, bytes);
|
||||
match nul_pos {
|
||||
Some(nul_pos) => {
|
||||
let subslice = &bytes[..nul_pos + 1];
|
||||
// FIXME(const-hack) replace with range index
|
||||
let subslice = unsafe { crate::slice::from_raw_parts(bytes.as_ptr(), nul_pos + 1) };
|
||||
// SAFETY: We know there is a nul byte at nul_pos, so this slice
|
||||
// (ending at the nul byte) is a well-formed C string.
|
||||
Ok(unsafe { CStr::from_bytes_with_nul_unchecked(subslice) })
|
||||
|
@ -561,8 +561,7 @@ impl CStr {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_cstr_methods", issue = "101719")]
|
||||
pub const fn to_bytes(&self) -> &[u8] {
|
||||
pub fn to_bytes(&self) -> &[u8] {
|
||||
let bytes = self.to_bytes_with_nul();
|
||||
// SAFETY: to_bytes_with_nul returns slice with length at least 1
|
||||
unsafe { bytes.get_unchecked(..bytes.len() - 1) }
|
||||
|
@ -613,8 +612,7 @@ impl CStr {
|
|||
/// assert_eq!(cstr.to_str(), Ok("foo"));
|
||||
/// ```
|
||||
#[stable(feature = "cstr_to_str", since = "1.4.0")]
|
||||
#[rustc_const_unstable(feature = "const_cstr_methods", issue = "101719")]
|
||||
pub const fn to_str(&self) -> Result<&str, str::Utf8Error> {
|
||||
pub fn to_str(&self) -> Result<&str, str::Utf8Error> {
|
||||
// N.B., when `CStr` is changed to perform the length check in `.to_bytes()`
|
||||
// instead of in `from_ptr()`, it may be worth considering if this should
|
||||
// be rewritten to do the UTF-8 check inline with the length calculation
|
||||
|
|
|
@ -86,7 +86,6 @@
|
|||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
use crate::fmt;
|
||||
use crate::intrinsics::const_eval_select;
|
||||
use crate::marker;
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
@ -239,21 +238,9 @@ pub trait Hash {
|
|||
where
|
||||
Self: Sized,
|
||||
{
|
||||
//FIXME(const_trait_impl): revert to only a for loop
|
||||
fn rt<T: Hash, H: Hasher>(data: &[T], state: &mut H) {
|
||||
for piece in data {
|
||||
piece.hash(state)
|
||||
}
|
||||
for piece in data {
|
||||
piece.hash(state)
|
||||
}
|
||||
const fn ct<T: Hash, H: Hasher>(data: &[T], state: &mut H) {
|
||||
let mut i = 0;
|
||||
while i < data.len() {
|
||||
data[i].hash(state);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
// SAFETY: same behavior, CT just uses while instead of for
|
||||
unsafe { const_eval_select((data, state), ct, rt) };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ macro_rules! load_int_le {
|
|||
/// Safety: this performs unchecked indexing of `buf` at `start..start+len`, so
|
||||
/// that must be in-bounds.
|
||||
#[inline]
|
||||
const unsafe fn u8to64_le(buf: &[u8], start: usize, len: usize) -> u64 {
|
||||
unsafe fn u8to64_le(buf: &[u8], start: usize, len: usize) -> u64 {
|
||||
debug_assert!(len < 8);
|
||||
let mut i = 0; // current byte index (from LSB) in the output u64
|
||||
let mut out = 0;
|
||||
|
|
|
@ -112,7 +112,6 @@
|
|||
#![feature(const_caller_location)]
|
||||
#![feature(const_cell_into_inner)]
|
||||
#![feature(const_char_from_u32_unchecked)]
|
||||
#![feature(const_cmp)]
|
||||
#![feature(const_cstr_methods)]
|
||||
#![feature(const_discriminant)]
|
||||
#![feature(const_eval_select)]
|
||||
|
@ -128,7 +127,6 @@
|
|||
#![feature(const_intrinsic_forget)]
|
||||
#![feature(const_ipv4)]
|
||||
#![feature(const_ipv6)]
|
||||
#![feature(const_is_char_boundary)]
|
||||
#![feature(const_likely)]
|
||||
#![feature(const_maybe_uninit_as_mut_ptr)]
|
||||
#![feature(const_maybe_uninit_assume_init)]
|
||||
|
@ -146,7 +144,6 @@
|
|||
#![feature(const_ptr_write)]
|
||||
#![feature(const_raw_ptr_comparison)]
|
||||
#![feature(const_replace)]
|
||||
#![feature(const_result_drop)]
|
||||
#![feature(const_size_of_val)]
|
||||
#![feature(const_size_of_val_raw)]
|
||||
#![feature(const_slice_from_raw_parts_mut)]
|
||||
|
|
|
@ -116,8 +116,7 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
|
|||
/// assert!(!(f32::NAN..1.0).contains(&0.5));
|
||||
/// ```
|
||||
#[stable(feature = "range_contains", since = "1.35.0")]
|
||||
#[rustc_const_unstable(feature = "const_range_bounds", issue = "108082")]
|
||||
pub const fn contains<U>(&self, item: &U) -> bool
|
||||
pub fn contains<U>(&self, item: &U) -> bool
|
||||
where
|
||||
Idx: PartialOrd<U>,
|
||||
U: ?Sized + PartialOrd<Idx>,
|
||||
|
@ -143,8 +142,7 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
|
|||
/// assert!( (f32::NAN..5.0).is_empty());
|
||||
/// ```
|
||||
#[stable(feature = "range_is_empty", since = "1.47.0")]
|
||||
#[rustc_const_unstable(feature = "const_range_bounds", issue = "108082")]
|
||||
pub const fn is_empty(&self) -> bool {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
!(self.start < self.end)
|
||||
}
|
||||
}
|
||||
|
@ -538,9 +536,8 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
|
|||
/// assert!(r.is_empty());
|
||||
/// ```
|
||||
#[stable(feature = "range_is_empty", since = "1.47.0")]
|
||||
#[rustc_const_unstable(feature = "const_range_bounds", issue = "108082")]
|
||||
#[inline]
|
||||
pub const fn is_empty(&self) -> bool {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.exhausted || !(self.start <= self.end)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -386,9 +386,7 @@ impl<T> NeverShortCircuit<T> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn wrap_mut_2<A, B>(
|
||||
mut f: impl FnMut(A, B) -> T,
|
||||
) -> impl FnMut(A, B) -> Self {
|
||||
pub fn wrap_mut_2<A, B>(mut f: impl FnMut(A, B) -> T) -> impl FnMut(A, B) -> Self {
|
||||
move |a, b| NeverShortCircuit(f(a, b))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -547,7 +547,6 @@
|
|||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
use crate::iter::{self, FromIterator, FusedIterator, TrustedLen};
|
||||
use crate::marker::Destruct;
|
||||
use crate::panicking::{panic, panic_str};
|
||||
use crate::pin::Pin;
|
||||
use crate::{
|
||||
|
@ -967,11 +966,7 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn unwrap_or(self, default: T) -> T
|
||||
where
|
||||
T: Destruct,
|
||||
{
|
||||
pub fn unwrap_or(self, default: T) -> T {
|
||||
match self {
|
||||
Some(x) => x,
|
||||
None => default,
|
||||
|
@ -989,11 +984,9 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn unwrap_or_else<F>(self, f: F) -> T
|
||||
pub fn unwrap_or_else<F>(self, f: F) -> T
|
||||
where
|
||||
F: FnOnce() -> T,
|
||||
F: Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(x) => x,
|
||||
|
@ -1022,8 +1015,7 @@ impl<T> Option<T> {
|
|||
/// [`FromStr`]: crate::str::FromStr
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn unwrap_or_default(self) -> T
|
||||
pub fn unwrap_or_default(self) -> T
|
||||
where
|
||||
T: Default,
|
||||
{
|
||||
|
@ -1089,11 +1081,9 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn map<U, F>(self, f: F) -> Option<U>
|
||||
pub fn map<U, F>(self, f: F) -> Option<U>
|
||||
where
|
||||
F: FnOnce(T) -> U,
|
||||
F: Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(x) => Some(f(x)),
|
||||
|
@ -1118,11 +1108,9 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "result_option_inspect", issue = "91345")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn inspect<F>(self, f: F) -> Self
|
||||
pub fn inspect<F>(self, f: F) -> Self
|
||||
where
|
||||
F: FnOnce(&T),
|
||||
F: Destruct,
|
||||
{
|
||||
if let Some(ref x) = self {
|
||||
f(x);
|
||||
|
@ -1151,12 +1139,9 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn map_or<U, F>(self, default: U, f: F) -> U
|
||||
pub fn map_or<U, F>(self, default: U, f: F) -> U
|
||||
where
|
||||
F: FnOnce(T) -> U,
|
||||
F: Destruct,
|
||||
U: Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(t) => f(t),
|
||||
|
@ -1180,13 +1165,10 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn map_or_else<U, D, F>(self, default: D, f: F) -> U
|
||||
pub fn map_or_else<U, D, F>(self, default: D, f: F) -> U
|
||||
where
|
||||
D: FnOnce() -> U,
|
||||
D: Destruct,
|
||||
F: FnOnce(T) -> U,
|
||||
F: Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(t) => f(t),
|
||||
|
@ -1217,11 +1199,7 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn ok_or<E>(self, err: E) -> Result<T, E>
|
||||
where
|
||||
E: Destruct,
|
||||
{
|
||||
pub fn ok_or<E>(self, err: E) -> Result<T, E> {
|
||||
match self {
|
||||
Some(v) => Ok(v),
|
||||
None => Err(err),
|
||||
|
@ -1246,11 +1224,9 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn ok_or_else<E, F>(self, err: F) -> Result<T, E>
|
||||
pub fn ok_or_else<E, F>(self, err: F) -> Result<T, E>
|
||||
where
|
||||
F: FnOnce() -> E,
|
||||
F: Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(v) => Ok(v),
|
||||
|
@ -1274,8 +1250,7 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "option_deref", since = "1.40.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn as_deref(&self) -> Option<&T::Target>
|
||||
pub fn as_deref(&self) -> Option<&T::Target>
|
||||
where
|
||||
T: Deref,
|
||||
{
|
||||
|
@ -1301,8 +1276,7 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "option_deref", since = "1.40.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn as_deref_mut(&mut self) -> Option<&mut T::Target>
|
||||
pub fn as_deref_mut(&mut self) -> Option<&mut T::Target>
|
||||
where
|
||||
T: DerefMut,
|
||||
{
|
||||
|
@ -1388,12 +1362,7 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn and<U>(self, optb: Option<U>) -> Option<U>
|
||||
where
|
||||
T: Destruct,
|
||||
U: Destruct,
|
||||
{
|
||||
pub fn and<U>(self, optb: Option<U>) -> Option<U> {
|
||||
match self {
|
||||
Some(_) => optb,
|
||||
None => None,
|
||||
|
@ -1430,11 +1399,9 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn and_then<U, F>(self, f: F) -> Option<U>
|
||||
pub fn and_then<U, F>(self, f: F) -> Option<U>
|
||||
where
|
||||
F: FnOnce(T) -> Option<U>,
|
||||
F: Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(x) => f(x),
|
||||
|
@ -1468,12 +1435,9 @@ impl<T> Option<T> {
|
|||
/// [`Some(t)`]: Some
|
||||
#[inline]
|
||||
#[stable(feature = "option_filter", since = "1.27.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn filter<P>(self, predicate: P) -> Self
|
||||
pub fn filter<P>(self, predicate: P) -> Self
|
||||
where
|
||||
T: Destruct,
|
||||
P: FnOnce(&T) -> bool,
|
||||
P: Destruct,
|
||||
{
|
||||
if let Some(x) = self {
|
||||
if predicate(&x) {
|
||||
|
@ -1512,11 +1476,7 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn or(self, optb: Option<T>) -> Option<T>
|
||||
where
|
||||
T: Destruct,
|
||||
{
|
||||
pub fn or(self, optb: Option<T>) -> Option<T> {
|
||||
match self {
|
||||
Some(x) => Some(x),
|
||||
None => optb,
|
||||
|
@ -1538,11 +1498,9 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn or_else<F>(self, f: F) -> Option<T>
|
||||
pub fn or_else<F>(self, f: F) -> Option<T>
|
||||
where
|
||||
F: FnOnce() -> Option<T>,
|
||||
F: Destruct,
|
||||
{
|
||||
match self {
|
||||
Some(x) => Some(x),
|
||||
|
@ -1573,11 +1531,7 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "option_xor", since = "1.37.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn xor(self, optb: Option<T>) -> Option<T>
|
||||
where
|
||||
T: Destruct,
|
||||
{
|
||||
pub fn xor(self, optb: Option<T>) -> Option<T> {
|
||||
match (self, optb) {
|
||||
(Some(a), None) => Some(a),
|
||||
(None, Some(b)) => Some(b),
|
||||
|
@ -1611,11 +1565,7 @@ impl<T> Option<T> {
|
|||
#[must_use = "if you intended to set a value, consider assignment instead"]
|
||||
#[inline]
|
||||
#[stable(feature = "option_insert", since = "1.53.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn insert(&mut self, value: T) -> &mut T
|
||||
where
|
||||
T: Destruct,
|
||||
{
|
||||
pub fn insert(&mut self, value: T) -> &mut T {
|
||||
*self = Some(value);
|
||||
|
||||
// SAFETY: the code above just filled the option
|
||||
|
@ -1644,11 +1594,7 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "option_entry", since = "1.20.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn get_or_insert(&mut self, value: T) -> &mut T
|
||||
where
|
||||
T: Destruct,
|
||||
{
|
||||
pub fn get_or_insert(&mut self, value: T) -> &mut T {
|
||||
if let None = *self {
|
||||
*self = Some(value);
|
||||
}
|
||||
|
@ -1679,12 +1625,11 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "option_get_or_insert_default", issue = "82901")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn get_or_insert_default(&mut self) -> &mut T
|
||||
pub fn get_or_insert_default(&mut self) -> &mut T
|
||||
where
|
||||
T: Default,
|
||||
{
|
||||
const fn default<T: Default>() -> T {
|
||||
fn default<T: Default>() -> T {
|
||||
T::default()
|
||||
}
|
||||
|
||||
|
@ -1710,11 +1655,9 @@ impl<T> Option<T> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "option_entry", since = "1.20.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn get_or_insert_with<F>(&mut self, f: F) -> &mut T
|
||||
pub fn get_or_insert_with<F>(&mut self, f: F) -> &mut T
|
||||
where
|
||||
F: FnOnce() -> T,
|
||||
F: Destruct,
|
||||
{
|
||||
if let None = *self {
|
||||
// the compiler isn't smart enough to know that we are not dropping a `T`
|
||||
|
@ -1794,12 +1737,7 @@ impl<T> Option<T> {
|
|||
/// assert_eq!(x.zip(z), None);
|
||||
/// ```
|
||||
#[stable(feature = "option_zip_option", since = "1.46.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn zip<U>(self, other: Option<U>) -> Option<(T, U)>
|
||||
where
|
||||
T: Destruct,
|
||||
U: Destruct,
|
||||
{
|
||||
pub fn zip<U>(self, other: Option<U>) -> Option<(T, U)> {
|
||||
match (self, other) {
|
||||
(Some(a), Some(b)) => Some((a, b)),
|
||||
_ => None,
|
||||
|
@ -1835,13 +1773,9 @@ impl<T> Option<T> {
|
|||
/// assert_eq!(x.zip_with(None, Point::new), None);
|
||||
/// ```
|
||||
#[unstable(feature = "option_zip", issue = "70086")]
|
||||
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
|
||||
pub const fn zip_with<U, F, R>(self, other: Option<U>, f: F) -> Option<R>
|
||||
pub fn zip_with<U, F, R>(self, other: Option<U>, f: F) -> Option<R>
|
||||
where
|
||||
F: FnOnce(T, U) -> R,
|
||||
F: Destruct,
|
||||
T: Destruct,
|
||||
U: Destruct,
|
||||
{
|
||||
match (self, other) {
|
||||
(Some(a), Some(b)) => Some(f(a, b)),
|
||||
|
@ -1867,12 +1801,7 @@ impl<T, U> Option<(T, U)> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "unzip_option", since = "1.66.0")]
|
||||
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
|
||||
pub const fn unzip(self) -> (Option<T>, Option<U>)
|
||||
where
|
||||
T: Destruct,
|
||||
U: Destruct,
|
||||
{
|
||||
pub fn unzip(self) -> (Option<T>, Option<U>) {
|
||||
match self {
|
||||
Some((a, b)) => (Some(a), Some(b)),
|
||||
None => (None, None),
|
||||
|
@ -1922,8 +1851,7 @@ impl<T> Option<&T> {
|
|||
/// ```
|
||||
#[must_use = "`self` will be dropped if the result is not used"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_option_cloned", issue = "91582")]
|
||||
pub const fn cloned(self) -> Option<T>
|
||||
pub fn cloned(self) -> Option<T>
|
||||
where
|
||||
T: Clone,
|
||||
{
|
||||
|
@ -1974,8 +1902,7 @@ impl<T> Option<&mut T> {
|
|||
/// ```
|
||||
#[must_use = "`self` will be dropped if the result is not used"]
|
||||
#[stable(since = "1.26.0", feature = "option_ref_mut_cloned")]
|
||||
#[rustc_const_unstable(feature = "const_option_cloned", issue = "91582")]
|
||||
pub const fn cloned(self) -> Option<T>
|
||||
pub fn cloned(self) -> Option<T>
|
||||
where
|
||||
T: Clone,
|
||||
{
|
||||
|
|
|
@ -1650,9 +1650,8 @@ impl<T> *const [T] {
|
|||
/// }
|
||||
/// ```
|
||||
#[unstable(feature = "slice_ptr_get", issue = "74265")]
|
||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||
#[inline]
|
||||
pub const unsafe fn get_unchecked<I>(self, index: I) -> *const I::Output
|
||||
pub unsafe fn get_unchecked<I>(self, index: I) -> *const I::Output
|
||||
where
|
||||
I: SliceIndex<[T]>,
|
||||
{
|
||||
|
|
|
@ -2036,9 +2036,8 @@ impl<T> *mut [T] {
|
|||
/// }
|
||||
/// ```
|
||||
#[unstable(feature = "slice_ptr_get", issue = "74265")]
|
||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||
#[inline(always)]
|
||||
pub const unsafe fn get_unchecked_mut<I>(self, index: I) -> *mut I::Output
|
||||
pub unsafe fn get_unchecked_mut<I>(self, index: I) -> *mut I::Output
|
||||
where
|
||||
I: SliceIndex<[T]>,
|
||||
{
|
||||
|
|
|
@ -676,9 +676,8 @@ impl<T> NonNull<[T]> {
|
|||
/// }
|
||||
/// ```
|
||||
#[unstable(feature = "slice_ptr_get", issue = "74265")]
|
||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||
#[inline]
|
||||
pub const unsafe fn get_unchecked_mut<I>(self, index: I) -> NonNull<I::Output>
|
||||
pub unsafe fn get_unchecked_mut<I>(self, index: I) -> NonNull<I::Output>
|
||||
where
|
||||
I: SliceIndex<[T]>,
|
||||
{
|
||||
|
|
|
@ -70,7 +70,8 @@ impl<T: Sized> Unique<T> {
|
|||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn dangling() -> Self {
|
||||
Self::from(NonNull::dangling())
|
||||
// FIXME(const-hack) replace with `From`
|
||||
Unique { pointer: NonNull::dangling(), _marker: PhantomData }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,7 +135,9 @@ impl<T: ?Sized> Unique<T> {
|
|||
#[must_use = "`self` will be dropped if the result is not used"]
|
||||
#[inline]
|
||||
pub const fn cast<U>(self) -> Unique<U> {
|
||||
Unique::from(self.pointer.cast())
|
||||
// FIXME(const-hack): replace with `From`
|
||||
// SAFETY: is `NonNull`
|
||||
unsafe { Unique::new_unchecked(self.pointer.cast().as_ptr()) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -489,7 +489,6 @@
|
|||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
use crate::iter::{self, FromIterator, FusedIterator, TrustedLen};
|
||||
use crate::marker::Destruct;
|
||||
use crate::ops::{self, ControlFlow, Deref, DerefMut};
|
||||
use crate::{convert, fmt, hint};
|
||||
|
||||
|
@ -629,11 +628,7 @@ impl<T, E> Result<T, E> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_result_drop", issue = "92384")]
|
||||
pub const fn ok(self) -> Option<T>
|
||||
where
|
||||
E: Destruct,
|
||||
{
|
||||
pub fn ok(self) -> Option<T> {
|
||||
match self {
|
||||
Ok(x) => Some(x),
|
||||
Err(_) => None,
|
||||
|
@ -656,11 +651,7 @@ impl<T, E> Result<T, E> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_result_drop", issue = "92384")]
|
||||
pub const fn err(self) -> Option<E>
|
||||
where
|
||||
T: Destruct,
|
||||
{
|
||||
pub fn err(self) -> Option<E> {
|
||||
match self {
|
||||
Ok(_) => None,
|
||||
Err(x) => Some(x),
|
||||
|
@ -1283,14 +1274,8 @@ impl<T, E> Result<T, E> {
|
|||
/// assert_eq!(x.and(y), Ok("different result type"));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "const_result_drop", issue = "92384")]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub const fn and<U>(self, res: Result<U, E>) -> Result<U, E>
|
||||
where
|
||||
T: Destruct,
|
||||
U: Destruct,
|
||||
E: Destruct,
|
||||
{
|
||||
pub fn and<U>(self, res: Result<U, E>) -> Result<U, E> {
|
||||
match self {
|
||||
Ok(_) => res,
|
||||
Err(e) => Err(e),
|
||||
|
@ -1364,14 +1349,8 @@ impl<T, E> Result<T, E> {
|
|||
/// assert_eq!(x.or(y), Ok(2));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "const_result_drop", issue = "92384")]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub const fn or<F>(self, res: Result<T, F>) -> Result<T, F>
|
||||
where
|
||||
T: Destruct,
|
||||
E: Destruct,
|
||||
F: Destruct,
|
||||
{
|
||||
pub fn or<F>(self, res: Result<T, F>) -> Result<T, F> {
|
||||
match self {
|
||||
Ok(v) => Ok(v),
|
||||
Err(_) => res,
|
||||
|
@ -1422,13 +1401,8 @@ impl<T, E> Result<T, E> {
|
|||
/// assert_eq!(x.unwrap_or(default), default);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "const_result_drop", issue = "92384")]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub const fn unwrap_or(self, default: T) -> T
|
||||
where
|
||||
T: Destruct,
|
||||
E: Destruct,
|
||||
{
|
||||
pub fn unwrap_or(self, default: T) -> T {
|
||||
match self {
|
||||
Ok(t) => t,
|
||||
Err(_) => default,
|
||||
|
@ -1979,9 +1953,7 @@ impl<T, E> ops::Try for Result<T, E> {
|
|||
}
|
||||
|
||||
#[unstable(feature = "try_trait_v2", issue = "84277")]
|
||||
impl<T, E, F: From<E>> ops::FromResidual<Result<convert::Infallible, E>>
|
||||
for Result<T, F>
|
||||
{
|
||||
impl<T, E, F: From<E>> ops::FromResidual<Result<convert::Infallible, E>> for Result<T, F> {
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn from_residual(residual: Result<convert::Infallible, E>) -> Self {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Original implementation taken from rust-memchr.
|
||||
// Copyright 2015 Andrew Gallant, bluss and Nicolas Koch
|
||||
|
||||
use crate::cmp;
|
||||
use crate::mem;
|
||||
|
||||
const LO_USIZE: usize = usize::repeat_u8(0x01);
|
||||
|
|
|
@ -333,10 +333,9 @@ impl<T> [T] {
|
|||
/// assert_eq!(None, v.get(0..4));
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn get<I>(&self, index: I) -> Option<&I::Output>
|
||||
pub fn get<I>(&self, index: I) -> Option<&I::Output>
|
||||
where
|
||||
I: SliceIndex<Self>,
|
||||
{
|
||||
|
@ -359,10 +358,9 @@ impl<T> [T] {
|
|||
/// assert_eq!(x, &[0, 42, 2]);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn get_mut<I>(&mut self, index: I) -> Option<&mut I::Output>
|
||||
pub fn get_mut<I>(&mut self, index: I) -> Option<&mut I::Output>
|
||||
where
|
||||
I: SliceIndex<Self>,
|
||||
{
|
||||
|
@ -392,10 +390,9 @@ impl<T> [T] {
|
|||
/// }
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const unsafe fn get_unchecked<I>(&self, index: I) -> &I::Output
|
||||
pub unsafe fn get_unchecked<I>(&self, index: I) -> &I::Output
|
||||
where
|
||||
I: SliceIndex<Self>,
|
||||
{
|
||||
|
@ -430,10 +427,9 @@ impl<T> [T] {
|
|||
/// assert_eq!(x, &[1, 13, 4]);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const unsafe fn get_unchecked_mut<I>(&mut self, index: I) -> &mut I::Output
|
||||
pub unsafe fn get_unchecked_mut<I>(&mut self, index: I) -> &mut I::Output
|
||||
where
|
||||
I: SliceIndex<Self>,
|
||||
{
|
||||
|
@ -678,9 +674,8 @@ impl<T> [T] {
|
|||
/// assert!(v == [3, 2, 1]);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_reverse", issue = "100784")]
|
||||
#[inline]
|
||||
pub const fn reverse(&mut self) {
|
||||
pub fn reverse(&mut self) {
|
||||
let half_len = self.len() / 2;
|
||||
let Range { start, end } = self.as_mut_ptr_range();
|
||||
|
||||
|
@ -703,7 +698,7 @@ impl<T> [T] {
|
|||
revswap(front_half, back_half, half_len);
|
||||
|
||||
#[inline]
|
||||
const fn revswap<T>(a: &mut [T], b: &mut [T], n: usize) {
|
||||
fn revswap<T>(a: &mut [T], b: &mut [T], n: usize) {
|
||||
debug_assert!(a.len() == n);
|
||||
debug_assert!(b.len() == n);
|
||||
|
||||
|
|
|
@ -206,9 +206,8 @@ impl str {
|
|||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "is_char_boundary", since = "1.9.0")]
|
||||
#[rustc_const_unstable(feature = "const_is_char_boundary", issue = "none")]
|
||||
#[inline]
|
||||
pub const fn is_char_boundary(&self, index: usize) -> bool {
|
||||
pub fn is_char_boundary(&self, index: usize) -> bool {
|
||||
// 0 is always ok.
|
||||
// Test for 0 explicitly so that it can optimize out the check
|
||||
// easily and skip reading string data for that case.
|
||||
|
@ -436,9 +435,8 @@ impl str {
|
|||
/// assert!(v.get(..42).is_none());
|
||||
/// ```
|
||||
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
|
||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||
#[inline]
|
||||
pub const fn get<I: SliceIndex<str>>(&self, i: I) -> Option<&I::Output> {
|
||||
pub fn get<I: SliceIndex<str>>(&self, i: I) -> Option<&I::Output> {
|
||||
i.get(self)
|
||||
}
|
||||
|
||||
|
@ -469,9 +467,8 @@ impl str {
|
|||
/// assert_eq!("HEllo", v);
|
||||
/// ```
|
||||
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
|
||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||
#[inline]
|
||||
pub const fn get_mut<I: SliceIndex<str>>(&mut self, i: I) -> Option<&mut I::Output> {
|
||||
pub fn get_mut<I: SliceIndex<str>>(&mut self, i: I) -> Option<&mut I::Output> {
|
||||
i.get_mut(self)
|
||||
}
|
||||
|
||||
|
@ -502,9 +499,8 @@ impl str {
|
|||
/// }
|
||||
/// ```
|
||||
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
|
||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||
#[inline]
|
||||
pub const unsafe fn get_unchecked<I: SliceIndex<str>>(&self, i: I) -> &I::Output {
|
||||
pub unsafe fn get_unchecked<I: SliceIndex<str>>(&self, i: I) -> &I::Output {
|
||||
// SAFETY: the caller must uphold the safety contract for `get_unchecked`;
|
||||
// the slice is dereferenceable because `self` is a safe reference.
|
||||
// The returned pointer is safe because impls of `SliceIndex` have to guarantee that it is.
|
||||
|
@ -538,12 +534,8 @@ impl str {
|
|||
/// }
|
||||
/// ```
|
||||
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
|
||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||
#[inline]
|
||||
pub const unsafe fn get_unchecked_mut<I: SliceIndex<str>>(
|
||||
&mut self,
|
||||
i: I,
|
||||
) -> &mut I::Output {
|
||||
pub unsafe fn get_unchecked_mut<I: SliceIndex<str>>(&mut self, i: I) -> &mut I::Output {
|
||||
// SAFETY: the caller must uphold the safety contract for `get_unchecked_mut`;
|
||||
// the slice is dereferenceable because `self` is a safe reference.
|
||||
// The returned pointer is safe because impls of `SliceIndex` have to guarantee that it is.
|
||||
|
|
|
@ -735,8 +735,7 @@ impl Duration {
|
|||
#[stable(feature = "duration_float", since = "1.38.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")]
|
||||
pub const fn from_secs_f64(secs: f64) -> Duration {
|
||||
pub fn from_secs_f64(secs: f64) -> Duration {
|
||||
match Duration::try_from_secs_f64(secs) {
|
||||
Ok(v) => v,
|
||||
Err(e) => panic!("{}", e.description()),
|
||||
|
@ -773,8 +772,7 @@ impl Duration {
|
|||
#[stable(feature = "duration_float", since = "1.38.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")]
|
||||
pub const fn from_secs_f32(secs: f32) -> Duration {
|
||||
pub fn from_secs_f32(secs: f32) -> Duration {
|
||||
match Duration::try_from_secs_f32(secs) {
|
||||
Ok(v) => v,
|
||||
Err(e) => panic!("{}", e.description()),
|
||||
|
@ -798,8 +796,7 @@ impl Duration {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")]
|
||||
pub const fn mul_f64(self, rhs: f64) -> Duration {
|
||||
pub fn mul_f64(self, rhs: f64) -> Duration {
|
||||
Duration::from_secs_f64(rhs * self.as_secs_f64())
|
||||
}
|
||||
|
||||
|
@ -820,8 +817,7 @@ impl Duration {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")]
|
||||
pub const fn mul_f32(self, rhs: f32) -> Duration {
|
||||
pub fn mul_f32(self, rhs: f32) -> Duration {
|
||||
Duration::from_secs_f32(rhs * self.as_secs_f32())
|
||||
}
|
||||
|
||||
|
@ -842,8 +838,7 @@ impl Duration {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")]
|
||||
pub const fn div_f64(self, rhs: f64) -> Duration {
|
||||
pub fn div_f64(self, rhs: f64) -> Duration {
|
||||
Duration::from_secs_f64(self.as_secs_f64() / rhs)
|
||||
}
|
||||
|
||||
|
@ -866,8 +861,7 @@ impl Duration {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")]
|
||||
pub const fn div_f32(self, rhs: f32) -> Duration {
|
||||
pub fn div_f32(self, rhs: f32) -> Duration {
|
||||
Duration::from_secs_f32(self.as_secs_f32() / rhs)
|
||||
}
|
||||
|
||||
|
@ -1402,9 +1396,8 @@ impl Duration {
|
|||
/// assert_eq!(res, Ok(Duration::new(1, 2_929_688)));
|
||||
/// ```
|
||||
#[stable(feature = "duration_checked_float", since = "1.66.0")]
|
||||
#[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")]
|
||||
#[inline]
|
||||
pub const fn try_from_secs_f32(secs: f32) -> Result<Duration, TryFromFloatSecsError> {
|
||||
pub fn try_from_secs_f32(secs: f32) -> Result<Duration, TryFromFloatSecsError> {
|
||||
try_from_secs!(
|
||||
secs = secs,
|
||||
mantissa_bits = 23,
|
||||
|
@ -1479,9 +1472,8 @@ impl Duration {
|
|||
/// assert_eq!(res, Ok(Duration::new(1, 2_929_688)));
|
||||
/// ```
|
||||
#[stable(feature = "duration_checked_float", since = "1.66.0")]
|
||||
#[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")]
|
||||
#[inline]
|
||||
pub const fn try_from_secs_f64(secs: f64) -> Result<Duration, TryFromFloatSecsError> {
|
||||
pub fn try_from_secs_f64(secs: f64) -> Result<Duration, TryFromFloatSecsError> {
|
||||
try_from_secs!(
|
||||
secs = secs,
|
||||
mantissa_bits = 52,
|
||||
|
|
Loading…
Reference in New Issue