mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
cleanup
This commit is contained in:
parent
0e4a542cfb
commit
d751bd08bf
6 changed files with 10 additions and 9 deletions
|
@ -79,7 +79,7 @@ impl<ID: ArenaId, T> Arena<ID, T> {
|
|||
self.data.push(value);
|
||||
ID::from_raw(id)
|
||||
}
|
||||
pub fn iter(&self) -> impl Iterator<Item = (ID, &T)> {
|
||||
pub fn iter(&self) -> impl Iterator<Item = (ID, &T)> + ExactSizeIterator {
|
||||
self.data.iter().enumerate().map(|(idx, value)| (ID::from_raw(RawId(idx as u32)), value))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ fn main_loop_inner(
|
|||
&& pending_libraries.is_empty()
|
||||
&& in_flight_libraries == 0
|
||||
{
|
||||
let n_packages: usize = state.workspaces.iter().map(|it| it.count()).sum();
|
||||
let n_packages: usize = state.workspaces.iter().map(|it| it.n_packages()).sum();
|
||||
if state.options.show_workspace_loaded {
|
||||
let msg = format!("workspace loaded, {} rust packages", n_packages);
|
||||
show_message(req::MessageType::Info, msg, msg_sender);
|
||||
|
|
|
@ -211,7 +211,7 @@ impl WorldSnapshot {
|
|||
} else {
|
||||
res.push_str("workspaces:\n");
|
||||
for w in self.workspaces.iter() {
|
||||
res += &format!("{} packages loaded\n", w.count());
|
||||
res += &format!("{} packages loaded\n", w.n_packages());
|
||||
}
|
||||
}
|
||||
res.push_str("\nanalysis:\n");
|
||||
|
|
|
@ -167,7 +167,7 @@ impl CargoWorkspace {
|
|||
Ok(CargoWorkspace { packages, targets, workspace_root: meta.workspace_root })
|
||||
}
|
||||
|
||||
pub fn packages<'a>(&'a self) -> impl Iterator<Item = Package> + 'a {
|
||||
pub fn packages<'a>(&'a self) -> impl Iterator<Item = Package> + ExactSizeIterator + 'a {
|
||||
self.packages.iter().map(|(id, _pkg)| id)
|
||||
}
|
||||
|
||||
|
|
|
@ -112,8 +112,7 @@ impl ProjectWorkspace {
|
|||
roots
|
||||
}
|
||||
ProjectWorkspace::Cargo { cargo, sysroot } => {
|
||||
let mut roots =
|
||||
Vec::with_capacity(cargo.packages().count() + sysroot.crates().count());
|
||||
let mut roots = Vec::with_capacity(cargo.packages().len() + sysroot.crates().len());
|
||||
for pkg in cargo.packages() {
|
||||
let root = pkg.root(&cargo).to_path_buf();
|
||||
let member = pkg.is_member(&cargo);
|
||||
|
@ -127,10 +126,12 @@ impl ProjectWorkspace {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn count(&self) -> usize {
|
||||
pub fn n_packages(&self) -> usize {
|
||||
match self {
|
||||
ProjectWorkspace::Json { project } => project.crates.len(),
|
||||
ProjectWorkspace::Cargo { cargo, .. } => cargo.packages().count(),
|
||||
ProjectWorkspace::Cargo { cargo, sysroot } => {
|
||||
cargo.packages().len() + sysroot.crates().len()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ impl Sysroot {
|
|||
self.by_name("std")
|
||||
}
|
||||
|
||||
pub fn crates<'a>(&'a self) -> impl Iterator<Item = SysrootCrate> + 'a {
|
||||
pub fn crates<'a>(&'a self) -> impl Iterator<Item = SysrootCrate> + ExactSizeIterator + 'a {
|
||||
self.crates.iter().map(|(id, _data)| id)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue