forked from gtk-rs/gtk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of gtk-rs#126 - gkoz:imports, r=gkoz
Add struct Imports to track the list of imported types and modules None
- Loading branch information
Showing
8 changed files
with
58 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use std::collections::btree_map::{BTreeMap, Iter}; | ||
|
||
use version::Version; | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct Imports { | ||
map: BTreeMap<String, Option<Version>>, | ||
} | ||
|
||
impl Imports { | ||
pub fn new() -> Imports { | ||
Imports { map: BTreeMap::new() } | ||
} | ||
|
||
pub fn add(&mut self, name: String, version: Option<Version>) { | ||
let entry = self.map.entry(name).or_insert(version); | ||
if version < *entry { | ||
*entry = version; | ||
} | ||
} | ||
|
||
pub fn remove(&mut self, name: &str) { | ||
self.map.remove(name); | ||
} | ||
|
||
pub fn iter(&self) -> Iter<String, Option<Version>> { | ||
self.map.iter() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters