Rust update.
This commit is contained in:
parent
7c9bd44916
commit
e57ba9e628
1 changed files with 5 additions and 5 deletions
10
src/lib.rs
10
src/lib.rs
|
@ -13,7 +13,7 @@ use std::intrinsics::{forget, TypeId};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::collections::hash_map;
|
use std::collections::hash_map;
|
||||||
use std::hash::{Hash, Hasher, Writer};
|
use std::hash::{Hash, Hasher, Writer};
|
||||||
use std::mem::{transmute, transmute_copy};
|
use std::mem::transmute;
|
||||||
use std::raw::TraitObject;
|
use std::raw::TraitObject;
|
||||||
|
|
||||||
pub use Entry::{Vacant, Occupied};
|
pub use Entry::{Vacant, Occupied};
|
||||||
|
@ -54,11 +54,11 @@ trait UncheckedAnyRefExt<'a> {
|
||||||
unsafe fn downcast_ref_unchecked<T: 'static>(self) -> &'a T;
|
unsafe fn downcast_ref_unchecked<T: 'static>(self) -> &'a T;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> UncheckedAnyRefExt<'a> for &'a (Any + 'a) {
|
impl<'a> UncheckedAnyRefExt<'a> for &'a Any {
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn downcast_ref_unchecked<T: 'static>(self) -> &'a T {
|
unsafe fn downcast_ref_unchecked<T: 'static>(self) -> &'a T {
|
||||||
// Get the raw representation of the trait object
|
// Get the raw representation of the trait object
|
||||||
let to: TraitObject = transmute_copy(&self);
|
let to: TraitObject = transmute(self);
|
||||||
|
|
||||||
// Extract the data pointer
|
// Extract the data pointer
|
||||||
transmute(to.data)
|
transmute(to.data)
|
||||||
|
@ -72,11 +72,11 @@ trait UncheckedAnyMutRefExt<'a> {
|
||||||
unsafe fn downcast_mut_unchecked<T: 'static>(self) -> &'a mut T;
|
unsafe fn downcast_mut_unchecked<T: 'static>(self) -> &'a mut T;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> UncheckedAnyMutRefExt<'a> for &'a mut (Any + 'a) {
|
impl<'a> UncheckedAnyMutRefExt<'a> for &'a mut Any {
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn downcast_mut_unchecked<T: 'static>(self) -> &'a mut T {
|
unsafe fn downcast_mut_unchecked<T: 'static>(self) -> &'a mut T {
|
||||||
// Get the raw representation of the trait object
|
// Get the raw representation of the trait object
|
||||||
let to: TraitObject = transmute_copy(&self);
|
let to: TraitObject = transmute(self);
|
||||||
|
|
||||||
// Extract the data pointer
|
// Extract the data pointer
|
||||||
transmute(to.data)
|
transmute(to.data)
|
||||||
|
|
Loading…
Add table
Reference in a new issue