-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
Default
const and add some const Default
impls
Full list of `impl const Default` types: - () - bool - char - std::ascii::Char - usize - u8 - u16 - u32 - u64 - u128 - i8 - i16 - i32 - i64 - i128 - f16 - f32 - f64 - f128 - std::marker::PhantomData<T> - Option<T> - std::iter::Empty<T> - std::ptr::Alignment - &[T] - &mut [T] - &str - &mut str - String - Vec<T>
- Loading branch information
Showing
12 changed files
with
72 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//@ run-pass | ||
#![feature(const_trait_impl)] | ||
#![allow(dead_code)] | ||
// alloc::string | ||
const STRING: String = Default::default(); | ||
// alloc::vec | ||
const VEC: Vec<()> = Default::default(); | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//@ run-pass | ||
#![feature(const_trait_impl, ptr_alignment_type, ascii_char, f16, f128)] | ||
#![allow(dead_code)] | ||
// core::default | ||
const UNIT: () = Default::default(); | ||
const BOOL: bool = Default::default(); | ||
const CHAR: char = Default::default(); | ||
const ASCII_CHAR: std::ascii::Char = Default::default(); | ||
const USIZE: usize = Default::default(); | ||
const U8: u8 = Default::default(); | ||
const U16: u16 = Default::default(); | ||
const U32: u32 = Default::default(); | ||
const U64: u64 = Default::default(); | ||
const U128: u128 = Default::default(); | ||
const I8: i8 = Default::default(); | ||
const I16: i16 = Default::default(); | ||
const I32: i32 = Default::default(); | ||
const I64: i64 = Default::default(); | ||
const I128: i128 = Default::default(); | ||
const F16: f16 = Default::default(); | ||
const F32: f32 = Default::default(); | ||
const F64: f64 = Default::default(); | ||
const F128: f128 = Default::default(); | ||
// core::marker | ||
const PHANTOM: std::marker::PhantomData<()> = Default::default(); | ||
// core::option | ||
const OPT: Option<i32> = Default::default(); | ||
// core::iter::sources::empty | ||
const EMPTY: std::iter::Empty<()> = Default::default(); | ||
// core::ptr::alignment | ||
const ALIGNMENT: std::ptr::Alignment = Default::default(); | ||
// core::slice | ||
const SLICE: &[()] = Default::default(); | ||
const MUT_SLICE: &mut [()] = Default::default(); | ||
//core::str | ||
const STR: &str = Default::default(); | ||
const MUT_STR: &mut str = Default::default(); | ||
|
||
fn main() {} |