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 c871d09 commit a700e47Copy full SHA for a700e47
library/core/src/cell/once.rs
@@ -376,14 +376,10 @@ impl<T: fmt::Debug> fmt::Debug for OnceCell<T> {
376
impl<T: Clone> Clone for OnceCell<T> {
377
#[inline]
378
fn clone(&self) -> OnceCell<T> {
379
- let res = OnceCell::new();
380
- if let Some(value) = self.get() {
381
- match res.set(value.clone()) {
382
- Ok(()) => (),
383
- Err(_) => unreachable!(),
384
- }
+ match self.get() {
+ Some(value) => OnceCell::from(value.clone()),
+ None => OnceCell::new(),
385
}
386
- res
387
388
389
0 commit comments