This can sometimes be useful because Rust borrowing rules normally prevent
moving a type that has been moved from. For example, this kind of code gets rejected:
-```rust,ignore
+```compile_fail,E0515
fn return_owned_and_referenced<'a>() -> (Vec<u8>, &'a [u8]) {
let v = vec![1, 2, 3, 4];
let s = &v[1..3];
as provided by `Box<T>`, `Rc<T>`, etc.
Also provided are typedefs for common owner type combinations,
-which allow for less verbose type signatures. For example, `BoxRef<T>` instead of `OwningRef<Box<T>, T>`.
+which allow for less verbose type signatures.
+For example, `BoxRef<T>` instead of `OwningRef<Box<T>, T>`.
The crate also provides the more advanced `OwningHandle` type,
which allows more freedom in bundling a dependent handle object
/// Helper trait for erasing the concrete type of what an owner dereferences to,
/// for example `Box<T> -> Box<Erased>`. This would be unneeded with
/// higher kinded types support in the language.
+#[allow(unused_lifetimes)]
pub unsafe trait IntoErased<'a> {
/// Owner with the dereference type substituted to `Erased`.
type Erased;
/// Helper trait for erasing the concrete type of what an owner dereferences to,
/// for example `Box<T> -> Box<Erased + Send>`. This would be unneeded with
/// higher kinded types support in the language.
+#[allow(unused_lifetimes)]
pub unsafe trait IntoErasedSend<'a> {
/// Owner with the dereference type substituted to `Erased + Send`.
type Erased: Send;
/// Helper trait for erasing the concrete type of what an owner dereferences to,
/// for example `Box<T> -> Box<Erased + Send + Sync>`. This would be unneeded with
/// higher kinded types support in the language.
+#[allow(unused_lifetimes)]
pub unsafe trait IntoErasedSendSync<'a> {
/// Owner with the dereference type substituted to `Erased + Send + Sync`.
type Erased: Send + Sync;
}
}
- /// Erases the concrete base type of the owner with a trait object which implements `Send` and `Sync`.
+ /// Erases the concrete base type of the owner with a trait object
+ /// which implements `Send` and `Sync`.
///
/// This allows mixing of owned references with different owner base types.
pub fn erase_send_sync_owner<'a>(self) -> OwningRef<O::Erased, T>
}
}
- // TODO: wrap_owner
+ // UNIMPLEMENTED: wrap_owner
// FIXME: Naming convention?
/// A getter for the underlying owner.
}
}
- // TODO: wrap_owner
+ // UNIMPLEMENTED: wrap_owner
// FIXME: Naming convention?
/// A getter for the underlying owner.
}
impl<O, H> OwningHandle<O, H>
- where O: StableAddress, O::Target: ToHandle<Handle = H>, H: Deref,
+where
+ O: StableAddress<Target: ToHandle<Handle = H>>,
+ H: Deref,
{
/// Creates a new `OwningHandle` for a type that implements `ToHandle`. For types
/// that don't implement `ToHandle`, callers may invoke `new_with_fn`, which accepts
}
impl<O, H> OwningHandle<O, H>
- where O: StableAddress, O::Target: ToHandleMut<HandleMut = H>, H: DerefMut,
+where
+ O: StableAddress<Target: ToHandleMut<HandleMut = H>>,
+ H: DerefMut,
{
/// Creates a new mutable `OwningHandle` for a type that implements `ToHandleMut`.
pub fn new_mut(o: O) -> Self {