Skip to content

replace consume on hashmap/hashset with iterators #7719

Closed
@thestinger

Description

@thestinger
Contributor

These can just wrap the vector ones.

Activity

added a commit that references this issue on Jul 15, 2013

auto merge of #7806 : apasel422/rust/hash_consume, r=catamorphism

bluss

bluss commented on Jul 16, 2013

@bluss
Member

I'm looking at this. A tricky thing is that HashMap::consume empties the hashmap by mutable reference, while the consume iter takes it by value. Both alternatives have use cases.

This is problematic in librusti, which uses @mut HashMap and empties them with do map.consume ...

The workaround ends up looking like this:

@@ -163,7 +164,8 @@ impl Program {
             None => {}
         }

-        do self.newvars.consume |name, var| {
+        let newvars = util::replace(&mut self.newvars, HashMap::new());
+        for newvars.consume_iter().advance |(name, var)| {
             self.local_vars.insert(name, var);
         }

Not sure if this is acceptable.

added a commit that references this issue on Jul 18, 2013

auto merge of #7833 : blake2-ppc/rust/hashmap-consume, r=alexcrichton

bluss

bluss commented on Jul 22, 2013

@bluss
Member

is fixed

huonw

huonw commented on Jul 22, 2013

@huonw
Member

Fixed by #7833.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @huonw@thestinger@bluss

        Issue actions

          replace consume on hashmap/hashset with iterators · Issue #7719 · rust-lang/rust