From 1c7ea307cfd58bd428d10e3d05681ce3058ce4a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?joseLu=C3=ADs?= Date: Tue, 13 Feb 2024 12:04:44 +0100 Subject: [PATCH] implement `Default` for `AsciiChar` --- library/core/src/ascii/ascii_char.rs | 2 +- library/core/src/default.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/library/core/src/ascii/ascii_char.rs b/library/core/src/ascii/ascii_char.rs index 5f758af162477..34a05ac38884d 100644 --- a/library/core/src/ascii/ascii_char.rs +++ b/library/core/src/ascii/ascii_char.rs @@ -58,7 +58,7 @@ use crate::mem::transmute; #[unstable(feature = "ascii_char", issue = "110998")] #[repr(u8)] pub enum AsciiChar { - /// U+0000 + /// U+0000 (The default variant) #[unstable(feature = "ascii_char_variants", issue = "110998")] Null = 0, /// U+0001 diff --git a/library/core/src/default.rs b/library/core/src/default.rs index 16618b38769d2..a1303fcd82158 100644 --- a/library/core/src/default.rs +++ b/library/core/src/default.rs @@ -2,6 +2,8 @@ #![stable(feature = "rust1", since = "1.0.0")] +use crate::ascii::Char as AsciiChar; + /// A trait for giving a type a useful default value. /// /// Sometimes, you want to fall back to some kind of default value, and @@ -158,6 +160,7 @@ macro_rules! default_impl { default_impl! { (), (), "Returns the default value of `()`" } default_impl! { bool, false, "Returns the default value of `false`" } default_impl! { char, '\x00', "Returns the default value of `\\x00`" } +default_impl! { AsciiChar, AsciiChar::Null, "Returns the default value of `Null`" } default_impl! { usize, 0, "Returns the default value of `0`" } default_impl! { u8, 0, "Returns the default value of `0`" }