mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
Implement const Default for &CStr
This commit is contained in:
@@ -176,7 +176,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
}
|
||||
|
||||
#[stable(feature = "cstr_default", since = "1.10.0")]
|
||||
impl Default for &CStr {
|
||||
#[rustc_const_unstable(feature = "const_default", issue = "143894")]
|
||||
impl const Default for &CStr {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
c""
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
use core::ffi::CStr;
|
||||
|
||||
#[test]
|
||||
fn const_default() {
|
||||
const S: &CStr = <_>::default();
|
||||
assert_eq!(S, c"");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compares_as_u8s() {
|
||||
let a: &CStr = c"Hello!"; // Starts with ascii
|
||||
|
||||
Reference in New Issue
Block a user