Skip to content

Commit

Permalink
Fix module type_constructor, compile module under feature use_std
Browse files Browse the repository at this point in the history
  • Loading branch information
dmvict committed Jun 3, 2022
1 parent e4d33d5 commit b98dd63
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
3 changes: 2 additions & 1 deletion rust/test/dt/type_constructor/type_constructor_lib_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use type_constructor as TheModule;
mod inc;

// zzz : move to inc after implementing macro to check presence of a dependency
#[ cfg( not( feature = "use_std" ) ) ]
#[ cfg( feature = "use_std" ) ]
#[ test_tools::rustversion::nightly ]
#[ test ]
fn trybuild_tests()
Expand All @@ -21,6 +21,7 @@ fn trybuild_tests()
let t = trybuild::TestCases::new();
#[ cfg( any( feature = "make", feature = "dt_make" ) ) ]
t.compile_fail( "../../../rust/test/dt/type_constructor/dynamic/make/*.rs" );
/* xxx : rewiew */
t.compile_fail( "../../../rust/test/dt/type_constructor/dynamic/types/*.rs" );
}

10 changes: 7 additions & 3 deletions sample/rust/type_constructor_many_sample/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#[ allow( unused_imports ) ]
use type_constructor::prelude::*;

fn main()
{
types!( many MyMany : i32 );
let x = MyMany::from( [ 1, 2, 3 ] );
println!( "x : {:?}", x.0 );
#[ cfg( all( feature = "many", feature = "use_std" ) ) ]
{
types!( many MyMany : i32 );
let x = MyMany::from( [ 1, 2, 3 ] );
println!( "x : {:?}", x.0 );
}
}
19 changes: 19 additions & 0 deletions sample/rust/type_constructor_multiple_sample/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use type_constructor::prelude::*;

#[ cfg( all( feature = "many", feature = "use_std" ) ) ]
types!
{

Expand All @@ -21,6 +22,24 @@ types!

}

#[ cfg( all( feature = "many", not( feature = "use_std" ) ) ) ]
types!
{

single MySingle : f32;
single SingleWithParametrized : std::sync::Arc< T : Copy >;
single SingleWithParameter : < T >;

pair MyPair : f32;
pair PairWithParametrized : std::sync::Arc< T1 : Copy >, std::sync::Arc< T2 : Copy >;
pair PairWithParameter : < T1, T2 >;

pair MyHomoPair : f32;
pair HomoPairWithParametrized : std::sync::Arc< T : Copy >;
pair HomoPairWithParameter : < T >;

}

fn main()
{
}
9 changes: 6 additions & 3 deletions sample/rust/type_constructor_without_macro_sample/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ fn main()
let two_i32_in_tuple = type_constructor::HomoPair::< i32 >::from( ( 13, 31 ) );
dbg!( two_i32_in_tuple );
// vec_of_i32_in_tuple = HomoPair( 13, 31 )
let vec_of_i32_in_tuple = type_constructor::Many::< i32 >::from( [ 1, 2, 3 ] );
dbg!( vec_of_i32_in_tuple );
// vec_of_i32_in_tuple = Many([ 1, 2, 3 ])
#[ cfg( all( feature = "many", feature = "use_std" ) ) ]
{
let vec_of_i32_in_tuple = type_constructor::Many::< i32 >::from( [ 1, 2, 3 ] );
dbg!( vec_of_i32_in_tuple );
// vec_of_i32_in_tuple = Many([ 1, 2, 3 ])
}

}

0 comments on commit b98dd63

Please sign in to comment.