We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2e2945f commit 19cb91fCopy full SHA for 19cb91f
src/cargo/core/interning.rs
@@ -3,23 +3,14 @@ use serde::{Serialize, Serializer};
3
use std::fmt;
4
use std::sync::RwLock;
5
use std::collections::HashSet;
6
-use std::slice;
7
use std::str;
8
-use std::mem;
9
use std::ptr;
10
use std::cmp::Ordering;
11
use std::ops::Deref;
12
use std::hash::{Hash, Hasher};
13
14
pub fn leak(s: String) -> &'static str {
15
- let boxed = s.into_boxed_str();
16
- let ptr = boxed.as_ptr();
17
- let len = boxed.len();
18
- mem::forget(boxed);
19
- unsafe {
20
- let slice = slice::from_raw_parts(ptr, len);
21
- str::from_utf8_unchecked(slice)
22
- }
+ Box::leak(s.into_boxed_str())
23
}
24
25
lazy_static! {
0 commit comments