mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
make IdentIds expose an iterator of &str
This commit is contained in:
parent
b0c6cb4420
commit
5a5324f27e
4 changed files with 16 additions and 14 deletions
|
@ -129,8 +129,8 @@ impl<'a> Env<'a> {
|
|||
region,
|
||||
},
|
||||
self.ident_ids
|
||||
.idents()
|
||||
.map(|(_, string)| string.as_ref().into())
|
||||
.ident_strs()
|
||||
.map(|(_, string)| string.into())
|
||||
.collect(),
|
||||
)),
|
||||
}
|
||||
|
@ -146,9 +146,9 @@ impl<'a> Env<'a> {
|
|||
}
|
||||
None => {
|
||||
let exposed_values = exposed_ids
|
||||
.idents()
|
||||
.ident_strs()
|
||||
.filter(|(_, ident)| {
|
||||
ident.as_ref().starts_with(|c: char| c.is_lowercase())
|
||||
ident.starts_with(|c: char| c.is_lowercase())
|
||||
})
|
||||
.map(|(_, ident)| Lowercase::from(ident.as_ref()))
|
||||
.collect();
|
||||
|
|
|
@ -327,9 +327,9 @@ impl Scope {
|
|||
) -> ASTResult<()> {
|
||||
let ident_ids = get_module_ident_ids(all_ident_ids, &env.home)?.clone();
|
||||
|
||||
for (_, ident_ref) in ident_ids.idents() {
|
||||
for (_, ident_ref) in ident_ids.ident_strs() {
|
||||
self.introduce(
|
||||
ident_ref.as_inline_str().as_str().into(),
|
||||
ident_ref.into(),
|
||||
&env.exposed_ident_ids,
|
||||
get_module_ident_ids_mut(all_ident_ids, &env.home)?,
|
||||
Region::zero(),
|
||||
|
|
|
@ -104,8 +104,8 @@ impl<'a> Env<'a> {
|
|||
region,
|
||||
},
|
||||
self.ident_ids
|
||||
.idents()
|
||||
.map(|(_, string)| string.as_ref().into())
|
||||
.ident_strs()
|
||||
.map(|(_, string)| string.into())
|
||||
.collect(),
|
||||
);
|
||||
Err(error)
|
||||
|
@ -127,9 +127,9 @@ impl<'a> Env<'a> {
|
|||
}
|
||||
None => {
|
||||
let exposed_values = exposed_ids
|
||||
.idents()
|
||||
.ident_strs()
|
||||
.filter(|(_, ident)| {
|
||||
ident.as_ref().starts_with(|c: char| c.is_lowercase())
|
||||
ident.starts_with(|c: char| c.is_lowercase())
|
||||
})
|
||||
.map(|(_, ident)| Lowercase::from(ident.as_ref()))
|
||||
.collect();
|
||||
|
|
|
@ -542,11 +542,11 @@ pub struct IdentIds {
|
|||
}
|
||||
|
||||
impl IdentIds {
|
||||
pub fn idents(&self) -> impl Iterator<Item = (IdentId, &Ident)> {
|
||||
pub fn ident_strs(&self) -> impl Iterator<Item = (IdentId, &str)> {
|
||||
self.by_id
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(index, ident)| (IdentId(index as u32), ident))
|
||||
.map(|(index, ident)| (IdentId(index as u32), ident.as_inline_str().as_str()))
|
||||
}
|
||||
|
||||
pub fn add(&mut self, ident_name: Ident) -> IdentId {
|
||||
|
@ -639,8 +639,10 @@ impl IdentIds {
|
|||
|
||||
#[inline(always)]
|
||||
pub fn get_id(&self, ident_name: &Ident) -> Option<IdentId> {
|
||||
for (id, ident) in self.idents() {
|
||||
if ident_name == ident {
|
||||
let ident_name = ident_name.as_inline_str().as_str();
|
||||
|
||||
for (id, ident_str) in self.ident_strs() {
|
||||
if ident_name == ident_str {
|
||||
return Some(id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue