Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 #![cfg_attr(test, deny(warnings))]
2 #![deny(missing_docs)]
3 #![allow(dyn_drop)]
4
5 //! # traitobject
6 //!
7 //! Unsafe helpers for working with raw TraitObjects.
8
9 /// Get the data pointer from this trait object.
10 ///
11 /// Highly unsafe, as there is no information about the type of the data.
12 pub unsafe fn datarust-analyzer cargo destructure_traitobject 0.3.0 data().<T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#>(val: *const T) -> *const () {
13 val as *const ()
14 }
15
16 /// Get the data pointer from this trait object, mutably.
17 ///
18 /// Highly unsafe, as there is no information about the type of the data.
19 pub unsafe fn data_mutrust-analyzer cargo destructure_traitobject 0.3.0 data_mut().<T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#>(val: *mut T) -> *mut () {
20 val as *mut ()
21 }
22
23 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
24 fn test_simplerust-analyzer cargo destructure_traitobject 0.3.0 test_simple().() {
25 let x = &7 as &dyn Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#;
26 unsafe { assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(&7 == stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::transmuterust-analyzer cargo core https://github.com/rust-lang/rust/library/core intrinsics/transmute().::<_, &i32>(datarust-analyzer cargo destructure_traitobject 0.3.0 data().(x))) };
27 }
28
29 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
30 fn test_mutrust-analyzer cargo destructure_traitobject 0.3.0 test_mut().() {
31 let x = &mut 7 as &mut dyn Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#;
32 unsafe { assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(&mut 7 == stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::transmuterust-analyzer cargo core https://github.com/rust-lang/rust/library/core intrinsics/transmute().::<_, &i32>(data_mutrust-analyzer cargo destructure_traitobject 0.3.0 data_mut().(x))) };
33 }
34
35 /// A trait implemented for all trait objects.
36 ///
37 /// Implementations for all traits in std are provided.
38 pub unsafe trait Traitrust-analyzer cargo destructure_traitobject 0.3.0 Trait# {}
39
40 mod implsrust-analyzer cargo destructure_traitobject 0.3.0 impls/;
41