File tree Expand file tree Collapse file tree 2 files changed +54
-1
lines changed Expand file tree Collapse file tree 2 files changed +54
-1
lines changed Original file line number Diff line number Diff line change 3636 - name : Check ILASM
3737 run : ilasm --version
3838 - name : Run cargo tests
39- run : cargo test --verbose ::stable -- --skip f128 --skip num_test
39+ run : cargo test --verbose ::stable -- --skip f128 --skip num_test --skip simd --skip fuzz87
4040 linux_c_test :
4141 runs-on : ubuntu-22.04
4242 env :
Original file line number Diff line number Diff line change 1+ #![ feature(
2+ lang_items,
3+ adt_const_params,
4+ associated_type_defaults,
5+ core_intrinsics,
6+ let_chains,
7+ never_type,
8+ unsized_const_params,
9+ pointer_is_aligned_to
10+ ) ]
11+ #![ allow( internal_features, incomplete_features, unused_variables, dead_code) ]
12+ include ! ( "../common.rs" ) ;
13+ /// Name of an option. Either a string or a single char.
14+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
15+ enum Name {
16+ /// A string representing the long name of an option.
17+ /// For example: "help"
18+ Long ( String ) ,
19+ /// A char representing the short name of an option.
20+ /// For example: 'h'
21+ Short ( char ) ,
22+ }
23+ /// A description of a possible option.
24+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
25+ struct Opt {
26+ /// Name of the option
27+ name : Name ,
28+ }
29+ fn find_opt ( opts : & [ Opt ] , nm : & Name ) -> Option < usize > {
30+ // Search main options.
31+ let pos = opts. iter ( ) . position ( |opt| & opt. name == nm) ;
32+ if pos. is_some ( ) {
33+ return pos;
34+ }
35+
36+ None
37+ }
38+ fn main ( ) {
39+ test_eq ! (
40+ find_opt(
41+ & [
42+ Opt {
43+ name: Name :: Short ( 'b' ) ,
44+ } ,
45+ Opt {
46+ name: Name :: Short ( 'a' ) ,
47+ } ,
48+ ] ,
49+ & Name :: Short ( 'a' ) ,
50+ ) ,
51+ Some ( 1 )
52+ ) ;
53+ }
You can’t perform that action at this time.
0 commit comments