Skip to content

Commit

Permalink
Added symbol_values to object
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Aug 5, 2020
1 parent 4fb8306 commit 647c26c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions boa/src/builtins/object/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ impl Object {
symbols: self.symbol_properties.keys(),
}
}

#[inline]
pub fn symbol_values(&self) -> SymbolValues<'_> {
SymbolValues {
symbols: self.symbol_properties.values(),
}
}
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -162,3 +169,31 @@ impl ExactSizeIterator for SymbolKeys<'_> {
}

impl FusedIterator for SymbolKeys<'_> {}

#[derive(Debug, Clone)]
pub struct SymbolValues<'a> {
symbols: hash_map::Values<'a, RcSymbol, Property>,
}

impl<'a> Iterator for SymbolValues<'a> {
type Item = &'a Property;

#[inline]
fn next(&mut self) -> Option<Self::Item> {
self.symbols.next()
}

#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.symbols.size_hint()
}
}

impl ExactSizeIterator for SymbolValues<'_> {
#[inline]
fn len(&self) -> usize {
self.symbols.len()
}
}

impl FusedIterator for SymbolValues<'_> {}

0 comments on commit 647c26c

Please sign in to comment.