From 841c3dc7e5968f21be745cf45a64c04f5fcfbd85 Mon Sep 17 00:00:00 2001 From: Brian Bosak Date: Fri, 6 Dec 2024 13:27:30 -0800 Subject: [PATCH 1/2] Bind lifetimes of &str returned from Key by the lifetime of 'k rather than the lifetime of the Key struct --- src/kv/key.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kv/key.rs b/src/kv/key.rs index 9a64b956f..b0cea5cb1 100644 --- a/src/kv/key.rs +++ b/src/kv/key.rs @@ -45,7 +45,7 @@ impl<'k> Key<'k> { } /// Get a borrowed string from this key. - pub fn as_str(&self) -> &str { + pub fn as_str(&self) -> &'k str { self.key } } @@ -57,7 +57,7 @@ impl<'k> fmt::Display for Key<'k> { } impl<'k> AsRef for Key<'k> { - fn as_ref(&self) -> &str { + fn as_ref(&self) -> &'k str { self.as_str() } } From 42eb5118a15d754bdc41f443afe5243ff1754a16 Mon Sep 17 00:00:00 2001 From: gbbosak <51209748+gbbosak@users.noreply.github.com> Date: Fri, 6 Dec 2024 21:45:57 +0000 Subject: [PATCH 2/2] Revert AsRef impl, as the feature needed for that isn't yet stable. --- src/kv/key.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kv/key.rs b/src/kv/key.rs index b0cea5cb1..5221c98f1 100644 --- a/src/kv/key.rs +++ b/src/kv/key.rs @@ -57,7 +57,7 @@ impl<'k> fmt::Display for Key<'k> { } impl<'k> AsRef for Key<'k> { - fn as_ref(&self) -> &'k str { + fn as_ref(&self) -> &str { self.as_str() } }