From c3ab77989f371855446aa96cad524b81ffb1bd07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sat, 23 Dec 2017 07:00:45 +0100 Subject: [PATCH] Replace Term::as_str with Term::with_str which only allows access to the string in a closure --- src/libproc_macro/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 121ab68167be2..b9367458ea9f2 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -407,8 +407,8 @@ impl Term { /// Get a reference to the interned string. #[unstable(feature = "proc_macro", issue = "38356")] - pub fn as_str(&self) -> &str { - unsafe { &*(&*self.0.as_str() as *const str) } + pub fn with_str R, R>(self, f: F) -> R { + self.0.with_str(f) } }