From 3eb27ab0b4743f7c0a10eccb82b69fcd86c8733f Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Thu, 8 May 2025 09:43:07 -0500 Subject: [PATCH] Add Default for &Option --- library/core/src/option.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index aed5a043c11a3..c57b8f4cf7f90 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -2094,6 +2094,15 @@ impl Default for Option { } } +#[stable(feature = "option_ref_default", since = "CURRENT_RUSTC_VERSION")] +impl<'a, T> Default for &'a Option { + /// Returns `&None` + #[inline] + fn default() -> &'a Option { + &None + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl IntoIterator for Option { type Item = T;