Lines Matching +defs:init +defs:data

5 //! [Pinning][pinning] is Rust's way of ensuring data does not move.
30 //! The feature is enabled by default, thus by default `pin-init` will require a nightly compiler.
133 //! To declare an init macro/function you just return an [`impl PinInit<T, E>`]:
151 //! buffer: Box::init(pin_init::init_zeroed())?,
502 let mut $var = match $crate::__internal::StackInit::init($var, val) {
580 let mut $var = $crate::__internal::StackInit::init($var, val);
585 let mut $var = $crate::__internal::StackInit::init($var, val)?;
768 /// let init = pin_init!(&this in Buf {
774 /// let init = pin_init!(Buf {
794 /// This initializer is for initializing data in-place that might later be moved. If you want to
804 /// use pin_init::{init, Init, init_zeroed};
812 /// init!(Self {
817 /// # let _ = Box::init(BigBuf::new());
819 pub use pin_init_internal::init;
878 let data = unsafe { <$ty as $crate::__internal::HasPinData>::__pin_data() };
879 let init = $crate::__internal::AlwaysFail::<$field_ty>::new();
881 unsafe { data.$field(ptr, init) }.ok();
1041 /// use pin_init::{init, init_zeroed, Init};
1053 /// let foo = init!(Foo {
1145 pub const unsafe fn cast_pin_init<T, U, E>(init: impl PinInit<T, E>) -> impl PinInit<U, E> {
1148 let res = unsafe { pin_init_from_closure(|ptr: *mut U| init.__pinned_init(ptr.cast::<T>())) };
1164 pub const unsafe fn cast_init<T, U, E>(init: impl Init<T, E>) -> impl Init<U, E> {
1167 let res = unsafe { init_from_closure(|ptr: *mut U| init.__init(ptr.cast::<T>())) };
1193 /// let array: Box<[usize; 1_000]> = Box::init(init_array_from_fn(|i| i)).unwrap();
1202 let init = move |slot: *mut [T; N]| {
1205 let init = make_init(i);
1210 if let Err(e) = unsafe { init.__init(ptr) } {
1221 unsafe { init_from_closure(init) }
1245 let init = move |slot: *mut [T; N]| {
1248 let init = make_init(i);
1253 if let Err(e) = unsafe { init.__pinned_init(ptr) } {
1264 unsafe { pin_init_from_closure(init) }
1300 // - If `make_init` returns `Ok`, safety requirement are fulfilled by `init.__pinned_init`.
1301 // - The safety requirements of `init.__pinned_init` are fulfilled, since it's being called
1305 let init = make_init()?;
1306 init.__pinned_init(slot)
1328 /// Ok(init!(Foo { a: bar.a.into(), b: bar.b }? Error))
1335 /// initializer returned by the [`init!`] invocation.
1343 // - If `make_init` returns `Ok`, safety requirement are fulfilled by `init.__init`.
1344 // - The safety requirements of `init.__init` are fulfilled, since it's being called from an
1348 let init = make_init()?;
1349 init.__init(slot)
1403 fn write_init<E>(self, init: impl Init<T, E>) -> Result<Self::Initialized, E>;
1408 fn write_pin_init<E>(self, init: impl PinInit<T, E>) -> Result<Pin<Self::Initialized>, E>;
1414 fn write_init<E>(self, init: impl Init<T, E>) -> Result<Self::Initialized, E> {
1418 unsafe { init.__init(slot)? };
1424 fn write_pin_init<E>(self, init: impl PinInit<T, E>) -> Result<Pin<Self::Initialized>, E> {
1429 // The `'static` borrow guarantees the data will not be
1431 unsafe { init.__pinned_init(slot)? };
1737 fn pin_init<E>(init: impl PinInit<T, E>) -> impl PinInit<Self, E> {
1739 unsafe { cast_pin_init(init) }