Struct VaList
#[repr(transparent)]
pub struct VaList<'a> { pub(in ::ffi::va_list) inner: VaListInner, pub(in ::ffi::va_list) _marker: PhantomCovariantLifetime<'a> }
A variable argument list, ABI-compatible with va_list in C.
This type is created in c-variadic functions when ... is desugared. A VaList
is automatically initialized (equivalent to calling va_start in C).
use VaList;
/// # Safety
/// Must be passed at least `count` arguments of type `i32`.
unsafe extern "C"
/// # Safety
/// Must be passed at least `count` arguments of type `i32`.
unsafe
assert_eq!;
assert_eq!;
The VaList::next_arg method reads the next argument from the variable argument list,
and is equivalent to C va_arg.
Cloning a VaList performs the equivalent of C va_copy, producing an independent cursor
that arguments can be read from without affecting the original. Dropping a VaList performs
the equivalent of C va_end.
A VaList can be used across an FFI boundary, and fully matches the platform's va_list in
terms of layout and ABI.
Fields
inner: VaListInner_marker: PhantomCovariantLifetime<'a>
Implementations
impl VaList<'_>
const fn duplicate(&self) -> Self
impl<'f> VaList<'f>
const unsafe fn next_arg<T: VaArgSafe>(&mut self) -> TRead the next argument from the variable argument list.
Only types that implement
VaArgSafecan be read from a variable argument list.Safety
This function is safe to call only if all of the following conditions are satisfied:
- There is another c-variadic argument to read.
- The actual type of the argument
Uis compatible withT(as defined below). - If
UandTare both integer types, then the value passed by the caller must be representable in both types. - If
Tis notCopy, then it must not have already been read usingnext_argon a [clone][VaList::clone]d copy of thisVaList. (Currently, all types implementingVaArgSafealso implementCopy, but this may change in the future.)
Types
TandUare compatible when:
Trait Implementations
impl Debug for VaList<'_>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<'f> Clone for VaList<'f>
fn clone(&self) -> SelfClone the
VaList, producing a second independent cursor into the variable argument list.Corresponds to
va_copyin C.
impl<'f> Drop for VaList<'f>
fn drop(&mut self)Drop the
VaList.Corresponds to
va_endin C.
Auto Trait Implementations
impl<'a> !Send for VaList<'a>
impl<'a> !Sync for VaList<'a>
impl<'a> Freeze for VaList<'a>
impl<'a> RefUnwindSafe for VaList<'a>
impl<'a> Unpin for VaList<'a>
impl<'a> UnsafeUnpin for VaList<'a>
impl<'a> UnwindSafe for VaList<'a>
Blanket Implementations
impl<T> Any for VaList<'a>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for VaList<'a>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for VaList<'a>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for VaList<'a>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for VaList<'a>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> SizeHint for VaList<'a>
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for VaList<'a>
impl<T, U> Into<U> for VaList<'a>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for VaList<'a>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for VaList<'a>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>