Skip to main content

Av

Struct Av 

Source
pub struct Av(/* private fields */);

Implementations§

Source§

impl Av

Source

pub fn new(perl: &Perl) -> Av

Allocate a fresh, empty mortal AV.

Source

pub fn push(&self, perl: &Perl, sv: Sv)

Append sv to the end of the array. The Sv is refcount-inc’d before being handed to av_push because av_push takes ownership of one ref — and the caller’s mortal Sv would otherwise be freed at scope exit, leaving a dangling slot.

Source

pub fn into_rv(self, perl: &Perl) -> Rv<Av>

Wrap this AV in a fresh mortal RV (\@array in Perl). The returned Rv<Av> is the value you typically push to the Perl stack as the XS sub’s return.

Source

pub unsafe fn from_raw_unchecked(p: *mut AV) -> Av

Wrap a raw *mut AV without checking for null. Used by the #[xs_sub] proc-macro after it has dereferenced an &Av arg (caller passed \@arr and we’ve already SvROK / SvTYPE-checked the SV).

§Safety

p must be non-null and point to a valid AV that outlives the returned Av.

Source

pub fn len(&self, perl: &Perl) -> usize

Number of elements (scalar @array).

Source

pub fn get(&self, perl: &Perl, idx: usize) -> Option<Sv>

$arr[$idx], or None if the slot is empty / out of bounds. The returned Sv borrows from this AV — don’t keep it past any mutation of the AV.

Source

pub fn iter<'a>(&'a self, perl: &'a Perl) -> AvIter<'a>

Iterate over (0..len) yielding each slot as Option<Sv>. None for sparse / unallocated slots.

Source

pub fn as_ptr(&self) -> *mut AV

Raw pointer for FFI.

Trait Implementations§

Source§

impl Clone for Av

Source§

fn clone(&self) -> Av

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Av

Auto Trait Implementations§

§

impl Freeze for Av

§

impl RefUnwindSafe for Av

§

impl !Send for Av

§

impl !Sync for Av

§

impl Unpin for Av

§

impl UnsafeUnpin for Av

§

impl UnwindSafe for Av

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.