rust/library/core
Matthias Krüger 510fc3432e
Rollup merge of #129550 - kornelski:boxasstr, r=joshtriplett,dtolnay
Add str.as_str() for easy Deref to string slices

Working with `Box<str>` is cumbersome, because in places like `iter.filter()` it can end up being `&Box<str>` or even `&&Box<str>`, and such type doesn't always get auto-dereferenced as expected.

Dereferencing such box to `&str` requires ugly syntax like `&**boxed_str` or `&***boxed_str`, with the exact amount of `*`s.

`Box<str>` is [not easily comparable with other string types](https://github.com/rust-lang/rust/pull/129852) via `PartialEq`. `Box<str>` won't work for lookups in types like `HashSet<String>`, because `Borrow<String>` won't take types like `&Box<str>`. OTOH `set.contains(s.as_str())` works nicely regardless of levels of indirection.

`String` has a simple solution for this: the `as_str()` method, and `Box<str>` should too.
2024-09-23 06:45:32 +02:00
..
benches Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
src Rollup merge of #129550 - kornelski:boxasstr, r=joshtriplett,dtolnay 2024-09-23 06:45:32 +02:00
tests Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
Cargo.toml Port std library to RTEMS 2024-09-03 09:19:29 +02:00