File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ extern crate libcc2rs;
2+ use libcc2rs:: * ;
3+ use std:: cell:: RefCell ;
4+ use std:: collections:: BTreeMap ;
5+ use std:: io:: prelude:: * ;
6+ use std:: io:: { Read , Seek , Write } ;
7+ use std:: os:: fd:: AsFd ;
8+ use std:: rc:: { Rc , Weak } ;
9+ pub fn main ( ) {
10+ __cpp2rust_init_globals ( ) ;
11+ std:: process:: exit ( main_0 ( ) ) ;
12+ }
13+ fn main_0 ( ) -> i32 {
14+ let mut n: u32 = 17_u32 ;
15+ let d: Value < u32 > = Rc :: new ( RefCell :: new ( n) ) ;
16+ assert ! ( ( ( * d. borrow( ) ) == 17_u32 ) ) ;
17+ let mut name: Ptr < i8 > = Ptr :: < i8 > :: from_string_literal ( b"dir/file.txt" ) ;
18+ let p: Value < Vec < i8 > > = Rc :: new ( RefCell :: new ( {
19+ let mut __v = Vec :: new ( ) ;
20+ name. with_c_str ( |__s| __v. extend_from_slice ( __s) ) ;
21+ __v. push ( 0 ) ;
22+ __v
23+ } ) ) ;
24+ let mut s: Vec < i8 > = ( * p. borrow ( ) ) . clone ( ) ;
25+ assert ! ( ( ( s. len( ) - 1 ) == 12_usize ) ) ;
26+ assert ! (
27+ Ptr :: <i8 >:: from_string_literal( b"dir/file.txt" )
28+ . with_c_str( |__s| s[ ..s. len( ) . saturating_sub( 1 ) ] == * __s)
29+ ) ;
30+ return 0 ;
31+ }
32+ pub fn __cpp2rust_init_globals ( ) { }
Original file line number Diff line number Diff line change 1+ extern crate libc;
2+ use libc:: * ;
3+ extern crate libcc2rs;
4+ use libcc2rs:: * ;
5+ use std:: collections:: BTreeMap ;
6+ use std:: io:: { Read , Seek , Write } ;
7+ use std:: os:: fd:: { AsFd , FromRawFd , IntoRawFd } ;
8+ use std:: rc:: Rc ;
9+ pub fn main ( ) {
10+ unsafe {
11+ __cpp2rust_init_globals ( ) ;
12+ std:: process:: exit ( main_0 ( ) as i32 ) ;
13+ }
14+ }
15+ unsafe fn main_0 ( ) -> i32 {
16+ let mut n: u32 = 17_u32 ;
17+ let mut d: u32 = n;
18+ assert ! ( ( ( d) == ( 17_u32 ) ) ) ;
19+ let mut name: * const libc:: c_char = c"dir/file.txt" . as_ptr ( ) ;
20+ let mut p: Vec < libc:: c_char > = {
21+ let mut __v = :: std:: ffi:: CStr :: from_ptr ( name)
22+ . to_bytes ( )
23+ . iter ( )
24+ . map ( |& __b| __b as libc:: c_char )
25+ . collect :: < Vec < libc:: c_char > > ( ) ;
26+ __v. push ( 0 ) ;
27+ __v
28+ } ;
29+ let mut s: Vec < libc:: c_char > = p;
30+ assert ! ( ( ( s. len( ) - 1 ) == ( 12_usize ) ) ) ;
31+ assert ! (
32+ s == {
33+ let s = c"dir/file.txt" . as_ptr( ) ;
34+ std:: slice:: from_raw_parts( s, ( 0 ..) . take_while( |& i| * s. add( i) != 0 ) . count( ) + 1 )
35+ . to_vec( )
36+ }
37+ ) ;
38+ return 0 ;
39+ }
40+ pub unsafe fn __cpp2rust_init_globals ( ) { }
You can’t perform that action at this time.
0 commit comments