// This library is released under the same terms as Rust itself.
//! Leaky cows: convert a clone-on-write reference into a plain reference. If it's just the //! plain reference, just return that. If it's the owned structure, leak it and return a //! reference to it.
externcrate leak; use leak::Leak; use std::borrow::{Borrow, Cow, ToOwned};
impl<'a, B: ?Sized> LeakyCow<'a, B> for Cow<'a, B> where B: 'a + ToOwned, B::Owned: Leak<B> { fn leak(self) -> &'a B { matchself {
Cow::Owned(x) => x.leak(),
Cow::Borrowed(x) => x,
}
}
}
#[cfg(test)] mod test { usesuper::LeakyCow; use std::borrow::Cow; #[test] fn test_string() { let _ = { let c = Cow::Borrowed("Let it go!");
c.leak();
};
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-06-17)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.