mirror of
https://github.com/icewind1991/ivory.git
synced 2026-06-03 10:44:09 +02:00
borrow args
This commit is contained in:
parent
5b95e4370a
commit
43f4228408
1 changed files with 7 additions and 5 deletions
|
|
@ -40,29 +40,31 @@ impl ExecuteData {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn args(&self) -> ArgIterator {
|
||||
pub fn args<'a>(&'a self) -> ArgIterator<'a> {
|
||||
ArgIterator {
|
||||
base: self.get_arg_base(),
|
||||
count: self.num_args(),
|
||||
item: 0,
|
||||
lifetime: &()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ArgIterator {
|
||||
pub struct ArgIterator<'a> {
|
||||
base: *const ZVal,
|
||||
count: u32,
|
||||
item: u32,
|
||||
lifetime: &'a ()
|
||||
}
|
||||
|
||||
impl Iterator for ArgIterator {
|
||||
type Item = ZVal;
|
||||
impl<'a> Iterator for ArgIterator<'a> {
|
||||
type Item = &'a ZVal;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
if self.item < self.count {
|
||||
let val = unsafe { &*(self.base.add(self.item as usize)) };
|
||||
self.item += 1;
|
||||
Some((*val).clone())
|
||||
Some(val)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue