File: test_custom.rs

package info (click to toggle)
rust-ref-cast 1.0.25-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 268 kB
  • sloc: makefile: 2
file content (18 lines) | stat: -rw-r--r-- 368 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#[forbid(unsafe_code)]
mod forbid_unsafe {
    use ref_cast::{ref_cast_custom, RefCastCustom};

    #[derive(RefCastCustom)]
    #[repr(transparent)]
    pub struct Custom(#[allow(dead_code)] str);

    impl Custom {
        #[ref_cast_custom]
        pub fn new(s: &str) -> &Custom;
    }
}

#[test]
fn test_forbid_unsafe() {
    forbid_unsafe::Custom::new("...");
}