From 527c26a985e54104e69ed4c781b492c29b8ac77d Mon Sep 17 00:00:00 2001 From: Eric Kidd Date: Wed, 25 Oct 2023 20:07:10 -0400 Subject: [PATCH] Don't clone Scope::get --- src/infer.rs | 4 +++- src/scope.rs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/infer.rs b/src/infer.rs index b078582..d00e756 100644 --- a/src/infer.rs +++ b/src/infer.rs @@ -302,7 +302,9 @@ mod tests { } fn lookup(scope: &ScopeHandle, name: &str) -> Option> { - scope.get(&CaseInsensitiveIdent::new(name, Span::Unknown)) + scope + .get(&CaseInsensitiveIdent::new(name, Span::Unknown)) + .cloned() } macro_rules! assert_defines { diff --git a/src/scope.rs b/src/scope.rs index 98f7d70..4384f09 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -179,9 +179,9 @@ impl Scope { } /// Get a value from the scope. - pub fn get(&self, name: &CaseInsensitiveIdent) -> Option { + pub fn get<'scope>(&'scope self, name: &CaseInsensitiveIdent) -> Option<&'scope ScopeValue> { match self.names.get(name) { - Some(ScopeEntry::Defined(value)) => Some(value.to_owned()), + Some(ScopeEntry::Defined(value)) => Some(value), Some(ScopeEntry::Hidden) => None, None => { if let Some(parent) = self.parent.as_ref() {