traitobject-0.1.0/.gitignore01006440000765000002400000000207125073175560014243 0ustar0000000000000000.DS_Store *~ *# *.o *.so *.swp *.dylib *.dSYM *.dll *.rlib *.dummy *.exe *-test /doc/ /target/ /examples/* !/examples/*.rs Cargo.lock traitobject-0.1.0/.travis.yml01006440000765000002400000001075125073175560014370 0ustar0000000000000000language: rust sudo: false script: - cargo build - cargo test - cargo bench --no-run - cargo doc after_success: - if [ "$TRAVIS_PULL_REQUEST" == false && test == "TRAVIS_BRANCH" == "master" ]; then - curl https://raw.githubusercontent.com/reem/rust-gh-docs/master/make-docs.sh > docs.sh - chmod u+x docs.sh - ./docs.sh reem project-name env: global: secure: QPYL1XUr4CyK/2DXlsYC1eCpWRpyEiqQSd/FFVR+YdP/rOJ7AyAXQqPhfgjDBQwvc6E2fUiyYjoV/xe1a757DDeZKlgd8Lp20fSDwvNt/Ejx8ueh3h3kuOtgDpIGSKX/l+XC+ltDpzjhh7bowI2/fOEf+kE53jvu9i4PiLnKdlY= traitobject-0.1.0/Cargo.toml01006440000765000002400000001351130436241760014177 0ustar0000000000000000# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] name = "traitobject" version = "0.1.0" authors = ["Jonathan Reem "] description = "Unsafe helpers for working with raw trait objects." readme = "README.md" license = "MIT/Apache-2.0" repository = "https://github.com/reem/rust-traitobject.git" traitobject-0.1.0/Cargo.toml.orig01006440000765000002400000000430130436241760015133 0ustar0000000000000000[package] name = "traitobject" version = "0.1.0" authors = ["Jonathan Reem "] repository = "https://github.com/reem/rust-traitobject.git" description = "Unsafe helpers for working with raw trait objects." readme = "README.md" license = "MIT/Apache-2.0" traitobject-0.1.0/README.md01006440000765000002400000000554126445432760013541 0ustar0000000000000000# traitobject > Unsafe helpers for dealing with raw trait objects. ## Usage Use the crates.io repository; add this to your `Cargo.toml` along with the rest of your dependencies: ```toml [dependencies] traitobject = "*" ``` ## Author [Jonathan Reem](https://medium.com/@jreem) is the primary author and maintainer of traitobject. ## License MIT/Apache-2.0 traitobject-0.1.0/src/impls.rs01006440000765000002400000010761125256020500014524 0ustar0000000000000000use Trait; unsafe impl Trait for ::std::any::Any + Send { } unsafe impl Trait for ::std::any::Any + Sync { } unsafe impl Trait for ::std::any::Any + Send + Sync { } unsafe impl Trait for ::std::borrow::Borrow + Send { } unsafe impl Trait for ::std::borrow::Borrow + Sync { } unsafe impl Trait for ::std::borrow::Borrow + Send + Sync { } unsafe impl Trait for ::std::borrow::BorrowMut + Send { } unsafe impl Trait for ::std::borrow::BorrowMut + Sync { } unsafe impl Trait for ::std::borrow::BorrowMut + Send + Sync { } unsafe impl Trait for ::std::convert::AsMut + Send { } unsafe impl Trait for ::std::convert::AsMut + Sync { } unsafe impl Trait for ::std::convert::AsMut + Send + Sync { } unsafe impl Trait for ::std::convert::AsRef + Send { } unsafe impl Trait for ::std::convert::AsRef + Sync { } unsafe impl Trait for ::std::convert::AsRef + Send + Sync { } unsafe impl Trait for ::std::error::Error + Send { } unsafe impl Trait for ::std::error::Error + Sync { } unsafe impl Trait for ::std::error::Error + Send + Sync { } unsafe impl Trait for ::std::fmt::Binary + Send { } unsafe impl Trait for ::std::fmt::Binary + Sync { } unsafe impl Trait for ::std::fmt::Binary + Send + Sync { } unsafe impl Trait for ::std::fmt::Debug + Send { } unsafe impl Trait for ::std::fmt::Debug + Sync { } unsafe impl Trait for ::std::fmt::Debug + Send + Sync { } unsafe impl Trait for ::std::fmt::Display + Send { } unsafe impl Trait for ::std::fmt::Display + Sync { } unsafe impl Trait for ::std::fmt::Display + Send + Sync { } unsafe impl Trait for ::std::fmt::LowerExp + Send { } unsafe impl Trait for ::std::fmt::LowerExp + Sync { } unsafe impl Trait for ::std::fmt::LowerExp + Send + Sync { } unsafe impl Trait for ::std::fmt::LowerHex + Send { } unsafe impl Trait for ::std::fmt::LowerHex + Sync { } unsafe impl Trait for ::std::fmt::LowerHex + Send + Sync { } unsafe impl Trait for ::std::fmt::Octal + Send { } unsafe impl Trait for ::std::fmt::Octal + Sync { } unsafe impl Trait for ::std::fmt::Octal + Send + Sync { } unsafe impl Trait for ::std::fmt::Pointer + Send { } unsafe impl Trait for ::std::fmt::Pointer + Sync { } unsafe impl Trait for ::std::fmt::Pointer + Send + Sync { } unsafe impl Trait for ::std::fmt::UpperExp + Send { } unsafe impl Trait for ::std::fmt::UpperExp + Sync { } unsafe impl Trait for ::std::fmt::UpperExp + Send + Sync { } unsafe impl Trait for ::std::fmt::UpperHex + Send { } unsafe impl Trait for ::std::fmt::UpperHex + Sync { } unsafe impl Trait for ::std::fmt::UpperHex + Send + Sync { } unsafe impl Trait for ::std::fmt::Write + Send { } unsafe impl Trait for ::std::fmt::Write + Sync { } unsafe impl Trait for ::std::fmt::Write + Send + Sync { } unsafe impl Trait for ::std::hash::Hasher + Send { } unsafe impl Trait for ::std::hash::Hasher + Sync { } unsafe impl Trait for ::std::hash::Hasher + Send + Sync { } unsafe impl Trait for ::std::io::BufRead + Send { } unsafe impl Trait for ::std::io::BufRead + Sync { } unsafe impl Trait for ::std::io::BufRead + Send + Sync { } unsafe impl Trait for ::std::io::Read + Send { } unsafe impl Trait for ::std::io::Read + Sync { } unsafe impl Trait for ::std::io::Read + Send + Sync { } unsafe impl Trait for ::std::io::Seek + Send { } unsafe impl Trait for ::std::io::Seek + Sync { } unsafe impl Trait for ::std::io::Seek + Send + Sync { } unsafe impl Trait for ::std::io::Write + Send { } unsafe impl Trait for ::std::io::Write + Sync { } unsafe impl Trait for ::std::io::Write + Send + Sync { } unsafe impl Trait for ::std::iter::IntoIterator { } unsafe impl Trait for ::std::iter::Iterator + Send { } unsafe impl Trait for ::std::iter::Iterator + Sync { } unsafe impl Trait for ::std::iter::Iterator + Send + Sync { } unsafe impl Trait for ::std::marker::Send + Send { } unsafe impl Trait for ::std::marker::Send + Sync { } unsafe impl Trait for ::std::marker::Send + Send + Sync { } unsafe impl Trait for ::std::marker::Sync + Send { } unsafe impl Trait for ::std::marker::Sync + Sync { } unsafe impl Trait for ::std::marker::Sync + Send + Sync { } unsafe impl Trait for ::std::ops::Drop + Send { } unsafe impl Trait for ::std::ops::Drop + Sync { } unsafe impl Trait for ::std::ops::Drop + Send + Sync { } unsafe impl Trait for ::std::string::ToString + Send { } unsafe impl Trait for ::std::string::ToString + Sync { } unsafe impl Trait for ::std::string::ToString + Send + Sync { } traitobject-0.1.0/src/lib.rs01006440000765000002400000001645125256020400014146 0ustar0000000000000000#![cfg_attr(test, deny(warnings))] #![deny(missing_docs)] //! # traitobject //! //! Unsafe helpers for working with raw TraitObjects. use std::mem; /// Get the data pointer from this trait object. /// /// Highly unsafe, as there is no information about the type of the data. pub unsafe fn data(val: *const T) -> *const () { *mem::transmute::<*const *const T, *const *const ()>(&val) } /// Get the data pointer from this trait object, mutably. /// /// Highly unsafe, as there is no information about the type of the data. pub unsafe fn data_mut(mut val: *mut T) -> *mut () { *mem::transmute::<*mut *mut T, *mut *mut ()>(&mut val) } #[test] fn test_simple() { let x = &7 as &Send; unsafe { assert!(&7 == mem::transmute::<_, &i32>(data(x))) }; } /// A trait implemented for all trait objects. /// /// Implementations for all traits in std are provided. pub unsafe trait Trait {} mod impls;