Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/uefi/src/polyfill.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / uefi / src / polyfill.rs` 33 lines ยท 1167 bytes Raw Blame History 1 // SPDX-License-Identifier: MIT OR Apache-2.0 2 3 //! Polyfills for functions in the standard library that are currently gated 4 //! behind unstable features. 5 6 use core::mem::MaybeUninit; 7 use core::ptr; 8 #[cfg(feature = "alloc")] 9 use {alloc::vec::Vec, core::mem::ManuallyDrop}; 10 11 /// Polyfill for the unstable `MaybeUninit::slice_assume_init_ref` function. 12 /// 13 /// See . 14 pub const unsafe fn maybe_uninit_slice_assume_init_ref(s: &[MaybeUninit]) -> &[T] { 15 // SAFETY: The source layout matches the target view. 16 unsafe { &*(ptr::from_ref(s) as *const [T]) } 17 } 18 19 /// Polyfill for the unstable `MaybeUninit::slice_as_mut_ptr` function. 20 /// 21 /// See . 22 pub const fn maybe_uninit_slice_as_mut_ptr(s: &mut [MaybeUninit]) -> *mut T { 23 s.as_mut_ptr().cast::() 24 } 25 26 /// Polyfill for the unstable `Vec::into_raw_parts` function. 27 /// 28 /// See . 29 #[cfg(feature = "alloc")] 30 pub fn vec_into_raw_parts(v: Vec) -> (*mut T, usize, usize) { 31 let mut v = ManuallyDrop::new(v); 32 (v.as_mut_ptr(), v.len(), v.capacity()) 33 }