Commit a01e4df
authored
Rollup merge of rust-lang#98061 - WaffleLapkin:own_the_option, r=joshtriplett
Add `Option::owned`
This PR adds the following public library APIs:
```rust
impl<T: ?Sized> Option<&T> {
pub const fn owned(self) -> Option<T::Owned>
where
T: ~const ToOwned;
}
impl<T: ?Sized> Option<&mut T> {
pub fn owned(self) -> Option<T::Owned>
where
T: ~const ToOwned;
}
```
`Option::owned` is similar to `Option::cloned` and `Option::copied`, but uses the `ToOwned` trait.
---
I thought that would be easier, but since `ToOwned` is defined in the alloc crate this becomes incoherent :')6 files changed
+1155
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| 233 | + | |
233 | 234 | | |
234 | 235 | | |
| 236 | + | |
235 | 237 | | |
236 | 238 | | |
237 | 239 | | |
| |||
0 commit comments