Improve `String` to `&str` conversions
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
### Is your feature request related to a problem or challenge?
I was following to https://lucumr.pocoo.org/2025/3/23/from-string/ blog where a cheaper way introduced when converting a `String` to `&str` using `transmute_copy`.
I tried to check if extra allocations happening for the conversion using https://crates.io/crates/allocation-counter and tbh the crate shows the same number of allocations. But the test below shows interesting timings
```
let mut a: &str = "";
for s in strings {
a = s.as_str();
//a = unsafe { transmute_copy(&ManuallyDrop::new(s)) };
}
```
`strings` is 1_000_000 rows of 100 symbols each
Conversion using `a = s.as_str();` takes `Converted 1000000 strings in 65.978625ms`
Conversion using `transmute_copy` takes `Converted 1000000 strings in 6.238417ms` so 10x faster
### Describe the solution you'd like
_No response_
### Describe alternatives you've considered
_No response_
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.