|
@@ -1,11 +1,11 @@
|
|
|
use core::ops::{Deref, DerefMut};
|
|
|
-#[cfg(feature = "std")]
|
|
|
+#[cfg(feature = "use_std")]
|
|
|
use core::borrow::BorrowMut;
|
|
|
use core::fmt;
|
|
|
|
|
|
-#[cfg(feature = "std")]
|
|
|
+#[cfg(feature = "use_std")]
|
|
|
use std::boxed::Box;
|
|
|
-#[cfg(feature = "std")]
|
|
|
+#[cfg(feature = "use_std")]
|
|
|
use std::vec::Vec;
|
|
|
|
|
|
/// A managed object.
|
|
@@ -26,7 +26,7 @@ pub enum Managed<'a, T: 'a + ?Sized> {
|
|
|
/// Borrowed variant, either a single element or a slice.
|
|
|
Borrowed(&'a mut T),
|
|
|
/// Owned variant, only available with `std` present.
|
|
|
- #[cfg(feature = "std")]
|
|
|
+ #[cfg(feature = "use_std")]
|
|
|
Owned(Box<BorrowMut<T>>)
|
|
|
}
|
|
|
|
|
@@ -42,14 +42,14 @@ impl<'a, T: 'a + ?Sized> From<&'a mut T> for Managed<'a, T> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#[cfg(feature = "std")]
|
|
|
+#[cfg(feature = "use_std")]
|
|
|
impl<T, U: BorrowMut<T> + 'static> From<Box<U>> for Managed<'static, T> {
|
|
|
fn from(value: Box<U>) -> Self {
|
|
|
Managed::Owned(value)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#[cfg(feature = "std")]
|
|
|
+#[cfg(feature = "use_std")]
|
|
|
impl<T: 'static> From<Vec<T>> for Managed<'static, [T]> {
|
|
|
fn from(mut value: Vec<T>) -> Self {
|
|
|
value.shrink_to_fit();
|
|
@@ -63,7 +63,7 @@ impl<'a, T: 'a + ?Sized> Deref for Managed<'a, T> {
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
match self {
|
|
|
&Managed::Borrowed(ref value) => value,
|
|
|
- #[cfg(feature = "std")]
|
|
|
+ #[cfg(feature = "use_std")]
|
|
|
&Managed::Owned(ref value) => (**value).borrow()
|
|
|
}
|
|
|
}
|
|
@@ -73,7 +73,7 @@ impl<'a, T: 'a + ?Sized> DerefMut for Managed<'a, T> {
|
|
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
|
|
match self {
|
|
|
&mut Managed::Borrowed(ref mut value) => value,
|
|
|
- #[cfg(feature = "std")]
|
|
|
+ #[cfg(feature = "use_std")]
|
|
|
&mut Managed::Owned(ref mut value) => (**value).borrow_mut()
|
|
|
}
|
|
|
}
|