-
Notifications
You must be signed in to change notification settings - Fork 48
Make the crate no_std
+ alloc
#44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
64671df
b15845b
73e3da2
e4bda31
93f6068
6cc5506
9da3663
ae15433
a627cd9
75cc0d2
06f174b
a6c734f
2da8b06
0928883
366c90c
bb3e0e9
5f94576
3b0728e
c21ccd4
57010a0
64d2d94
69bb181
309d746
7b32a16
adb58e0
f9ad723
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
use super::NodeIter; | ||
use core::sync::atomic::Ordering; | ||
use crossbeam_epoch::Guard; | ||
use std::sync::atomic::Ordering; | ||
|
||
/// An iterator over a map's entries. | ||
/// | ||
/// See [`HashMap::iter`](crate::HashMap::iter) for details. | ||
#[derive(Debug)] | ||
pub struct Iter<'g, K, V> { | ||
pub(crate) node_iter: NodeIter<'g, K, V>, | ||
pub struct Iter<'g, K, V, L> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bah, then we'd have to duplicate all of these too. One other option here is to define a default value on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose that's why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, hashbrown uses ahash on no_std. It only uses an uninhabited default when compiled as a dependency for libstd (because the libstd build system is weird and makes dependencies difficult). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh ok, I misunderstood that context, and hashbrown doesn't need a lock like this. An uninhabited default might still work though, or we could use |
||
where | ||
L: lock_api::RawMutex, | ||
{ | ||
pub(crate) node_iter: NodeIter<'g, K, V, L>, | ||
pub(crate) guard: &'g Guard, | ||
} | ||
|
||
impl<'g, K, V> Iterator for Iter<'g, K, V> { | ||
impl<'g, K, V, L> Iterator for Iter<'g, K, V, L> | ||
where | ||
L: lock_api::RawMutex, | ||
{ | ||
type Item = (&'g K, &'g V); | ||
fn next(&mut self) -> Option<Self::Item> { | ||
let node = self.node_iter.next()?; | ||
|
@@ -26,11 +32,17 @@ impl<'g, K, V> Iterator for Iter<'g, K, V> { | |
/// | ||
/// See [`HashMap::keys`](crate::HashMap::keys) for details. | ||
#[derive(Debug)] | ||
pub struct Keys<'g, K, V> { | ||
pub(crate) node_iter: NodeIter<'g, K, V>, | ||
pub struct Keys<'g, K, V, L> | ||
where | ||
L: lock_api::RawMutex, | ||
{ | ||
pub(crate) node_iter: NodeIter<'g, K, V, L>, | ||
} | ||
|
||
impl<'g, K, V> Iterator for Keys<'g, K, V> { | ||
impl<'g, K, V, L> Iterator for Keys<'g, K, V, L> | ||
where | ||
L: lock_api::RawMutex, | ||
{ | ||
type Item = &'g K; | ||
fn next(&mut self) -> Option<Self::Item> { | ||
let node = self.node_iter.next()?; | ||
|
@@ -42,12 +54,18 @@ impl<'g, K, V> Iterator for Keys<'g, K, V> { | |
/// | ||
/// See [`HashMap::values`](crate::HashMap::values) for details. | ||
#[derive(Debug)] | ||
pub struct Values<'g, K, V> { | ||
pub(crate) node_iter: NodeIter<'g, K, V>, | ||
pub struct Values<'g, K, V, L> | ||
where | ||
L: lock_api::RawMutex, | ||
{ | ||
pub(crate) node_iter: NodeIter<'g, K, V, L>, | ||
pub(crate) guard: &'g Guard, | ||
} | ||
|
||
impl<'g, K, V> Iterator for Values<'g, K, V> { | ||
impl<'g, K, V, L> Iterator for Values<'g, K, V, L> | ||
where | ||
L: lock_api::RawMutex, | ||
{ | ||
type Item = &'g V; | ||
fn next(&mut self) -> Option<Self::Item> { | ||
let node = self.node_iter.next()?; | ||
|
@@ -61,9 +79,9 @@ impl<'g, K, V> Iterator for Values<'g, K, V> { | |
#[cfg(test)] | ||
mod tests { | ||
use crate::HashMap; | ||
use core::iter::FromIterator; | ||
use crossbeam_epoch as epoch; | ||
use std::collections::HashSet; | ||
use std::iter::FromIterator; | ||
|
||
#[test] | ||
fn iter() { | ||
|
Uh oh!
There was an error while loading. Please reload this page.