Skip to content

Commit c3ab779

Browse files
committed
Replace Term::as_str with Term::with_str which only allows access to the string in a closure
1 parent 04c7d30 commit c3ab779

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libproc_macro/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ impl Term {
407407

408408
/// Get a reference to the interned string.
409409
#[unstable(feature = "proc_macro", issue = "38356")]
410-
pub fn as_str(&self) -> &str {
411-
unsafe { &*(&*self.0.as_str() as *const str) }
410+
pub fn with_str<F: FnOnce(&str) -> R, R>(self, f: F) -> R {
411+
self.0.with_str(f)
412412
}
413413
}
414414

0 commit comments

Comments
 (0)