4

Mark `{array, slice}::{from_ref, from_mut}` as const fn by WaffleLapkin · Pull R...

 2 years ago
source link: https://github.com/rust-lang/rust/pull/90162
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Copy link

Contributor

WaffleLapkin commented 6 days ago

This PR marks the following APIs as const:

// core::array
pub const fn from_ref<T>(s: &T) -> &[T; 1];
pub const fn from_mut<T>(s: &mut T) -> &mut [T; 1];

// core::slice
pub const fn from_ref<T>(s: &T) -> &[T];
pub const fn from_mut<T>(s: &mut T) -> &mut [T];

Note that from_ref methods require const_raw_ptr_deref feature (which seems totally fine, since it's being stabilized, see #89551), from_mut methods require const_mut_refs (which seems fine too since this PR marks from_mut functions as const unstable).

r? @oli-obk


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK