-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afca75e
commit 7c34e79
Showing
16 changed files
with
360 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,30 @@ | ||
use std::fmt::Debug; | ||
use std::mem; | ||
|
||
use crate::types::Value; | ||
|
||
pub trait SuperType<T: Value> { | ||
fn upcast_internal(v: T) -> Self; | ||
fn upcast_internal(v: &T) -> Self; | ||
} | ||
|
||
#[doc(hidden)] | ||
/// Trait asserting that `Self` is a transparent wrapper around `Self::Inner` | ||
/// with identical representation and may be safely transmuted. | ||
/// | ||
/// # Safety | ||
/// `Self` must be `#[repr(transparent)]` with a field `Self::Inner`. The | ||
/// `TransparentWrapper::into_inner` must be implemented to avoid dependently | ||
/// sized types. | ||
pub unsafe trait TransparentWrapper: Sized { | ||
type Inner: Debug + Copy; | ||
|
||
fn into_inner(self) -> Self::Inner; | ||
|
||
fn wrap_ref(s: &Self::Inner) -> &Self { | ||
unsafe { mem::transmute(s) } | ||
} | ||
|
||
fn wrap_mut(s: &mut Self::Inner) -> &mut Self { | ||
unsafe { mem::transmute(s) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.