19f6c17df4
This makes the following API stable in const contexts: impl<T> Option<T> { pub const fn as_mut(&mut self) -> Option<&mut T>; pub const fn expect(self, msg: &str) -> T; pub const fn unwrap(self) -> T; pub const unsafe fn unwrap_unchecked(self) -> T; pub const fn take(&mut self) -> Option<T>; pub const fn replace(&mut self, value: T) -> Option<T>; } impl<T> Option<&T> { pub const fn copied(self) -> Option<T> where T: Copy; } impl<T> Option<&mut T> { pub const fn copied(self) -> Option<T> where T: Copy; } impl<T, E> Option<Result<T, E>> { pub const fn transpose(self) -> Result<Option<T>, E> } impl<T> Option<Option<T>> { pub const fn flatten(self) -> Option<T>; } The following functions make use of the unstable `const_precise_live_drops` feature: - `expect` - `unwrap` - `unwrap_unchecked` - `transpose` - `flatten` Fixes: <https://github.com/rust-lang/rust/issues/67441>
28 lines
714 B
Rust
28 lines
714 B
Rust
//! Support code for encoding and decoding types.
|
|
|
|
// tidy-alphabetical-start
|
|
#![allow(internal_features)]
|
|
#![allow(rustc::internal)]
|
|
#![cfg_attr(test, feature(test))]
|
|
#![doc(
|
|
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
|
|
html_playground_url = "https://play.rust-lang.org/",
|
|
test(attr(allow(unused_variables), deny(warnings)))
|
|
)]
|
|
#![doc(rust_logo)]
|
|
#![feature(core_intrinsics)]
|
|
#![feature(min_specialization)]
|
|
#![feature(never_type)]
|
|
#![feature(ptr_sub_ptr)]
|
|
#![feature(rustdoc_internals)]
|
|
#![warn(unreachable_pub)]
|
|
// tidy-alphabetical-end
|
|
|
|
pub use self::serialize::{Decodable, Decoder, Encodable, Encoder};
|
|
|
|
mod serialize;
|
|
|
|
pub mod int_overflow;
|
|
pub mod leb128;
|
|
pub mod opaque;
|