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.
2 parents 350004f + 177c0d3 commit d25589fCopy full SHA for d25589f
tests/run-pass/vec.rs
@@ -104,6 +104,14 @@ fn vec_truncate_ptr_stable() {
104
let _val = *v0;
105
}
106
107
+fn push_str_ptr_stable() {
108
+ let mut buf = String::with_capacity(11);
109
+ buf.push_str("hello");
110
+ let hello: &str = unsafe { &*(buf.as_str() as *const _) }; // laundering the lifetime -- we take care that `buf` does not reallocate, so that's okay.
111
+ buf.push_str(" world");
112
+ assert_eq!(format!("{}", hello), "hello");
113
+}
114
+
115
fn main() {
116
assert_eq!(vec_reallocate().len(), 5);
117
@@ -127,4 +135,5 @@ fn main() {
127
135
vec_push_ptr_stable();
128
136
vec_extend_ptr_stable();
129
137
vec_truncate_ptr_stable();
138
+ push_str_ptr_stable();
130
139
0 commit comments