1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #![allow(missing_docs)]
14 //! Contains struct definitions for the layout of compiler built-in types.
16 //! They can be used as targets of transmutes in unsafe code for manipulating
17 //! the raw representations directly.
19 //! Their definition should always match the ABI defined in `rustc::back::abi`.
24 /// The representation of a Rust slice
31 /// The representation of a Rust closure
38 /// The representation of a Rust procedure (`proc()`)
40 pub struct Procedure {
45 /// The representation of a Rust trait object.
47 /// This struct does not have a `Repr` implementation
48 /// because there is no way to refer to all trait objects generically.
50 pub struct TraitObject {
55 /// This trait is meant to map equivalences between raw structs and their
56 /// corresponding rust values.
57 pub trait Repr<T> for Sized? {
58 /// This function "unwraps" a rust value (without consuming it) into its raw
59 /// struct representation. This can be used to read/write different values
60 /// for the struct. This is a safe method because by default it does not
61 /// enable write-access to the fields of the return value in safe code.
63 fn repr(&self) -> T { unsafe { mem::transmute_copy(&self) } }
66 impl<T> Repr<Slice<T>> for [T] {}
67 impl Repr<Slice<u8>> for str {}