This commit handles the fallout from deprecating `_with` and `_equiv` methods.
let toknum = m.name("toknum");
let content = m.name("content");
- let proto_tok = tokens.find_equiv(&toknum).expect(format!("didn't find token {} in the map",
+ let proto_tok = tokens.get(&toknum).expect(format!("didn't find token {} in the map",
toknum).as_slice());
let nm = parse::token::intern(content);
//! ```
pub mod map;
-pub mod set;
\ No newline at end of file
+pub mod set;
//! `TrieMap` is ordered.
pub mod map;
-pub mod set;
\ No newline at end of file
+pub mod set;
match self.named {
None => "",
Some(ref h) => {
- match h.find_equiv(name) {
+ match h.get(name) {
None => "",
Some(i) => self.at(*i),
}
}
fn register_renamed(&mut self, old_name: &str, new_name: &str) {
- let target = match self.by_name.find_equiv(new_name) {
+ let target = match self.by_name.get(new_name) {
Some(&Id(lint_id)) => lint_id.clone(),
_ => panic!("invalid lint renaming of {} to {}", old_name, new_name)
};
fn find_lint(&self, lint_name: &str, sess: &Session, span: Option<Span>)
-> Option<LintId>
{
- match self.by_name.find_equiv(lint_name) {
+ match self.by_name.get(lint_name) {
Some(&Id(lint_id)) => Some(lint_id),
Some(&Renamed(ref new_name, lint_id)) => {
let warning = format!("lint {} has been renamed to {}",
match self.lint_groups.iter().map(|(&x, pair)| (x, pair.ref0().clone()))
.collect::<FnvHashMap<&'static str,
Vec<LintId>>>()
- .find_equiv(lint_name.as_slice()) {
+ .get(lint_name.as_slice()) {
Some(v) => {
v.iter()
.map(|lint_id: &LintId|
match self.lints.find_lint(lint_name.get(), &self.tcx.sess, Some(span)) {
Some(lint_id) => vec![(lint_id, level, span)],
None => {
- match self.lints.lint_groups.find_equiv(lint_name.get()) {
+ match self.lints.lint_groups.get(lint_name.get()) {
Some(&(ref v, _)) => v.iter()
.map(|lint_id: &LintId|
(*lint_id, level, span))
// `source` stores paths which are normalized which may be different
// from the strings on the command line.
let source = e.sess.cstore.get_used_crate_source(cnum).unwrap();
- match e.sess.opts.externs.find_equiv(name) {
+ match e.sess.opts.externs.get(name) {
Some(locs) => {
let found = locs.iter().any(|l| {
let l = fs::realpath(&Path::new(l.as_slice())).ok();
fn item_name(intr: &IdentInterner, item: rbml::Doc) -> ast::Name {
let name = reader::get_doc(item, tag_paths_data_name);
let string = name.as_str_slice();
- match intr.find_equiv(string) {
+ match intr.find(string) {
None => token::intern(string),
Some(val) => val,
}
Some(item) => item_sort(item) == 't',
}
}
-
debug!("filesearch: searching lib path");
let tlib_path = make_target_lib_path(self.sysroot,
self.triple);
- if !visited_dirs.contains_equiv(tlib_path.as_vec()) {
+ if !visited_dirs.contains(tlib_path.as_vec()) {
match f(&tlib_path) {
FileMatches => found = true,
FileDoesntMatch => ()
let tlib_path = make_rustpkg_lib_path(
self.sysroot, path, self.triple);
debug!("is {} in visited_dirs? {}", tlib_path.display(),
- visited_dirs.contains_equiv(&tlib_path.as_vec().to_vec()));
+ visited_dirs.contains(&tlib_path.as_vec().to_vec()));
- if !visited_dirs.contains_equiv(tlib_path.as_vec()) {
+ if !visited_dirs.contains(tlib_path.as_vec()) {
visited_dirs.insert(tlib_path.as_vec().to_vec());
// Don't keep searching the RUST_PATH if one match turns up --
// if we did, we'd get a "multiple matching crates" error
}
fn find_commandline_library(&mut self) -> Option<Library> {
- let locs = match self.sess.opts.externs.find_equiv(self.crate_name) {
+ let locs = match self.sess.opts.externs.get(self.crate_name) {
Some(s) => s,
None => return None,
};
fn visit_item(&mut self, item: &ast::Item) {
match extract(item.attrs.as_slice()) {
Some(value) => {
- let item_index = self.item_refs.find_equiv(&value).map(|x| *x);
+ let item_index = self.item_refs.get(value.get()).map(|x| *x);
match item_index {
Some(item_index) => {
ty: Type,
output: ty::t)
-> ValueRef {
- match externs.find_equiv(name) {
+ match externs.get(name) {
Some(n) => return *n,
None => {}
}
}
fn get_extern_rust_fn(ccx: &CrateContext, fn_ty: ty::t, name: &str, did: ast::DefId) -> ValueRef {
- match ccx.externs().borrow().find_equiv(name) {
+ match ccx.externs().borrow().get(name) {
Some(n) => return *n,
None => ()
}
let name = CString::new(llvm::LLVMGetValueName(val), false);
if !declared.contains(&name) &&
- !reachable.contains_equiv(name.as_str().unwrap()) {
+ !reachable.contains(name.as_str().unwrap()) {
llvm::SetLinkage(val, llvm::InternalLinkage);
}
}
}
fn file_metadata(cx: &CrateContext, full_path: &str) -> DIFile {
- match debug_context(cx).created_files.borrow().find_equiv(full_path) {
+ match debug_context(cx).created_files.borrow().get(full_path) {
Some(file_metadata) => return *file_metadata,
None => ()
}
}
pub fn find_type(&self, s: &str) -> Option<Type> {
- self.named_types.borrow().find_equiv(s).map(|x| Type::from_ref(*x))
+ self.named_types.borrow().get(s).map(|x| Type::from_ref(*x))
}
pub fn type_to_string(&self, ty: Type) -> String {
fn block(w: &mut fmt::Formatter, short: &str, longty: &str,
cur: &clean::Item, cx: &Context) -> fmt::Result {
- let items = match cx.sidebar.find_equiv(short) {
+ let items = match cx.sidebar.get(short) {
Some(items) => items.as_slice(),
None => return Ok(())
};
/// Otherwise, returns None.
pub fn find<'a>(&'a self, key: &str) -> Option<&'a Json>{
match self {
- &Object(ref map) => map.find_with(|s| key.cmp(s.as_slice())),
+ &Object(ref map) => map.get(key),
_ => None
}
}
pub fn search<'a>(&'a self, key: &str) -> Option<&'a Json> {
match self {
&Object(ref map) => {
- match map.find_with(|s| key.cmp(s.as_slice())) {
+ match map.get(key) {
Some(json_value) => Some(json_value),
None => {
for (_, v) in map.iter() {
m.insert("baz".to_string(), baz);
- assert_eq!(m.find_equiv("foo"), Some(&foo));
- assert_eq!(m.find_equiv("bar"), Some(&bar));
- assert_eq!(m.find_equiv("baz"), Some(&baz));
+ assert_eq!(m.get("foo"), Some(&foo));
+ assert_eq!(m.get("bar"), Some(&bar));
+ assert_eq!(m.get("baz"), Some(&baz));
- assert_eq!(m.find_equiv("qux"), None);
+ assert_eq!(m.get("qux"), None);
}
#[test]
}
pub fn find_description(&self, code: &str) -> Option<&'static str> {
- self.descriptions.find_equiv(code).map(|desc| *desc)
+ self.descriptions.get(code).map(|desc| *desc)
}
}
let name = interned_name.get();
p.expect(&token::Eq);
let e = p.parse_expr();
- match names.find_equiv(name) {
+ match names.get(name) {
None => {}
Some(prev) => {
ecx.span_err(e.span,
self.ecx.expr_path(path)
}
parse::CountIsName(n) => {
- let i = match self.name_positions.find_equiv(n) {
+ let i = match self.name_positions.get(n) {
Some(&i) => i,
None => 0, // error already emitted elsewhere
};
// Named arguments are converted to positional arguments at
// the end of the list of arguments
parse::ArgumentNamed(n) => {
- let i = match self.name_positions.find_equiv(n) {
+ let i = match self.name_positions.get(n) {
Some(&i) => i,
None => 0, // error already emitted elsewhere
};
use ast::Name;
+use std::borrow::BorrowFrom;
use std::collections::HashMap;
use std::cell::RefCell;
-use std::cmp::Equiv;
use std::fmt;
use std::hash::Hash;
use std::rc::Rc;
(*vect).len()
}
- pub fn find_equiv<Sized? Q: Hash + Equiv<T>>(&self, val: &Q) -> Option<Name> {
+ pub fn find<Sized? Q>(&self, val: &Q) -> Option<Name>
+ where Q: BorrowFrom<T> + Eq + Hash {
let map = self.map.borrow();
- match (*map).find_equiv(val) {
+ match (*map).get(val) {
Some(v) => Some(*v),
None => None,
}
}
}
+impl BorrowFrom<RcStr> for str {
+ fn borrow_from(owned: &RcStr) -> &str {
+ owned.string.as_slice()
+ }
+}
+
impl RcStr {
pub fn new(string: &str) -> RcStr {
RcStr {
pub fn intern(&self, val: &str) -> Name {
let mut map = self.map.borrow_mut();
- match map.find_equiv(val) {
+ match map.get(val) {
Some(&idx) => return idx,
None => (),
}
self.vect.borrow().len()
}
- pub fn find_equiv<Sized? Q:Hash + Equiv<RcStr>>(&self, val: &Q) -> Option<Name> {
- match (*self.map.borrow()).find_equiv(val) {
+ pub fn find<Sized? Q>(&self, val: &Q) -> Option<Name>
+ where Q: BorrowFrom<RcStr> + Eq + Hash {
+ match (*self.map.borrow()).get(val) {
Some(v) => Some(*v),
None => None,
}
if self.num_colors > color {
let s = expand(self.ti
.strings
- .find_equiv("setaf")
+ .get("setaf")
.unwrap()
.as_slice(),
&[Number(color as int)], &mut Variables::new());
if self.num_colors > color {
let s = expand(self.ti
.strings
- .find_equiv("setab")
+ .get("setab")
.unwrap()
.as_slice(),
&[Number(color as int)], &mut Variables::new());
attr::BackgroundColor(c) => self.bg(c),
_ => {
let cap = cap_for_attr(attr);
- let parm = self.ti.strings.find_equiv(cap);
+ let parm = self.ti.strings.get(cap);
if parm.is_some() {
let s = expand(parm.unwrap().as_slice(),
&[],
}
_ => {
let cap = cap_for_attr(attr);
- self.ti.strings.find_equiv(cap).is_some()
+ self.ti.strings.get(cap).is_some()
}
}
}
fn reset(&mut self) -> IoResult<()> {
- let mut cap = self.ti.strings.find_equiv("sgr0");
+ let mut cap = self.ti.strings.get("sgr0");
if cap.is_none() {
// are there any terminals that have color/attrs and not sgr0?
// Try falling back to sgr, then op
- cap = self.ti.strings.find_equiv("sgr");
+ cap = self.ti.strings.get("sgr");
if cap.is_none() {
- cap = self.ti.strings.find_equiv("op");
+ cap = self.ti.strings.get("op");
}
}
let s = cap.map_or(Err("can't find terminfo capability `sgr0`".to_string()), |op| {
}
let inf = ti.unwrap();
- let nc = if inf.strings.find_equiv("setaf").is_some()
- && inf.strings.find_equiv("setab").is_some() {
- inf.numbers.find_equiv("colors").map_or(0, |&n| n)
+ let nc = if inf.strings.get("setaf").is_some()
+ && inf.strings.get("setab").is_some() {
+ inf.numbers.get("colors").map_or(0, |&n| n)
} else { 0 };
return Some(box TerminfoTerminal {out: out,
// given a map, search for the frequency of a pattern
fn find(mm: &HashMap<Vec<u8> , uint>, key: String) -> uint {
let key = key.into_ascii().as_slice().to_lowercase().into_string();
- match mm.find_equiv(key.as_bytes()) {
+ match mm.get(key.as_bytes()) {
option::None => { return 0u; }
option::Some(&num) => { return num; }
}