Reduce explcit clones (#3793)

This commit is contained in:
Micha Reiser 2023-03-29 15:15:14 +02:00 committed by GitHub
parent b6f1fed424
commit 595cd065f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
73 changed files with 557 additions and 484 deletions

View file

@ -215,8 +215,19 @@ impl ScopeStack {
pub fn iter(&self) -> std::iter::Rev<std::slice::Iter<ScopeId>> {
self.0.iter().rev()
}
pub fn snapshot(&self) -> ScopeStackSnapshot {
ScopeStackSnapshot(self.0.len())
}
#[allow(clippy::needless_pass_by_value)]
pub fn restore(&mut self, snapshot: ScopeStackSnapshot) {
self.0.truncate(snapshot.0);
}
}
pub struct ScopeStackSnapshot(usize);
impl Default for ScopeStack {
fn default() -> Self {
Self(vec![ScopeId::global()])