Add note about possible allocation-sharing to Arc/Rc<str/[T]/CStr>::default.

This commit is contained in:
Zachary S 2024-05-11 07:11:36 -05:00
parent 5c6326ad79
commit 0b3ebb546f
3 changed files with 12 additions and 0 deletions

View File

@ -914,6 +914,8 @@ impl From<&CStr> for Rc<CStr> {
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
impl Default for Arc<CStr> {
/// Creates an empty CStr inside an Arc
///
/// This may or may not share an allocation with other Arcs.
#[inline]
fn default() -> Self {
let c_str: &CStr = Default::default();
@ -925,6 +927,8 @@ impl Default for Arc<CStr> {
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
impl Default for Rc<CStr> {
/// Creates an empty CStr inside an Rc
///
/// This may or may not share an allocation with other Rcs on the same thread.
#[inline]
fn default() -> Self {
let c_str: &CStr = Default::default();

View File

@ -2228,6 +2228,8 @@ impl<T: Default> Default for Rc<T> {
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
impl Default for Rc<str> {
/// Creates an empty str inside an Rc
///
/// This may or may not share an allocation with other Rcs on the same thread.
#[inline]
fn default() -> Self {
Rc::from("")
@ -2238,6 +2240,8 @@ impl Default for Rc<str> {
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
impl<T> Default for Rc<[T]> {
/// Creates an empty `[T]` inside an Rc
///
/// This may or may not share an allocation with other Rcs on the same thread.
#[inline]
fn default() -> Self {
let arr: [T; 0] = [];

View File

@ -3304,6 +3304,8 @@ impl<T: Default> Default for Arc<T> {
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
impl Default for Arc<str> {
/// Creates an empty str inside an Arc
///
/// This may or may not share an allocation with other Arcs.
#[inline]
fn default() -> Self {
Arc::from("")
@ -3314,6 +3316,8 @@ impl Default for Arc<str> {
#[stable(feature = "more_rc_default_impls", since = "CURRENT_RUSTC_VERSION")]
impl<T> Default for Arc<[T]> {
/// Creates an empty `[T]` inside an Arc
///
/// This may or may not share an allocation with other Arcs.
#[inline]
fn default() -> Self {
let arr: [T; 0] = [];