29
29
) ) ) ]
30
30
compile_error ! ( "at least one event type must be selected in the features!" ) ;
31
31
32
- #[ cfg( not( any( feature = "use_alloc " , feature = "use_heapless " ) ) ) ]
33
- compile_error ! ( "you must choose either 'use_alloc ' or 'use_heapless ' as a feature!" ) ;
32
+ #[ cfg( not( any( feature = "alloc " , feature = "heapless " ) ) ) ]
33
+ compile_error ! ( "you must choose either 'alloc ' or 'heapless ' as a feature!" ) ;
34
34
35
- #[ cfg( all( feature = "use_alloc " , feature = "use_heapless " ) ) ]
36
- compile_error ! ( "you must choose either 'use_alloc ' or 'use_heapless ' as a feature but not both!" ) ;
35
+ #[ cfg( all( feature = "alloc " , feature = "heapless " ) ) ]
36
+ compile_error ! ( "you must choose either 'alloc ' or 'heapless ' as a feature but not both!" ) ;
37
37
38
38
#[ cfg( feature = "accelerometer_event" ) ]
39
39
pub mod accelerometer_event;
@@ -59,12 +59,12 @@ use color_event::ColorEvent;
59
59
use core:: cmp:: min;
60
60
#[ cfg( feature = "gyro_event" ) ]
61
61
use gyro_event:: GyroEvent ;
62
- #[ cfg( feature = "use_heapless " ) ]
62
+ #[ cfg( feature = "heapless " ) ]
63
63
use heapless:: Vec ;
64
64
65
- #[ cfg( feature = "use_alloc " ) ]
65
+ #[ cfg( feature = "alloc " ) ]
66
66
extern crate alloc;
67
- #[ cfg( feature = "use_alloc " ) ]
67
+ #[ cfg( feature = "alloc " ) ]
68
68
use alloc:: vec:: Vec ;
69
69
use core:: error:: Error ;
70
70
use core:: fmt:: { Display , Formatter } ;
@@ -207,17 +207,17 @@ impl TryFrom<u8> for ControllerDataPackageType {
207
207
}
208
208
}
209
209
210
- #[ cfg( feature = "use_heapless " ) ]
210
+ #[ cfg( feature = "heapless " ) ]
211
211
type ParseResult < const MAX_RESULTS : usize > =
212
212
Vec < Result < ControllerEvent , ProtocolParseError > , MAX_RESULTS > ;
213
213
214
- #[ cfg( feature = "use_alloc " ) ]
214
+ #[ cfg( feature = "alloc " ) ]
215
215
type ParseResult < const MAX_RESULTS : usize > = Vec < Result < ControllerEvent , ProtocolParseError > > ;
216
- #[ cfg( feature = "use_alloc " ) ]
216
+ #[ cfg( feature = "alloc " ) ]
217
217
const MAX_RESULTS : usize = 0 ;
218
218
219
219
/// Parse the input string for commands. Unexpected content will be ignored if it's not formatted like a command!
220
- pub fn parse < #[ cfg( feature = "use_heapless " ) ] const MAX_RESULTS : usize > (
220
+ pub fn parse < #[ cfg( feature = "heapless " ) ] const MAX_RESULTS : usize > (
221
221
input : & [ u8 ] ,
222
222
) -> ParseResult < MAX_RESULTS > {
223
223
/// Simple state machine for the parser, represents whether the parser is seeking a start or has found it.
@@ -239,11 +239,11 @@ pub fn parse<#[cfg(feature = "use_heapless")] const MAX_RESULTS: usize>(
239
239
}
240
240
ParserState :: ParseCommand => {
241
241
let data_package = extract_and_parse_command ( & input[ ( pos - 1 ) ..] ) ;
242
- #[ cfg( feature = "use_alloc " ) ]
242
+ #[ cfg( feature = "alloc " ) ]
243
243
result. push ( data_package) ;
244
- #[ cfg( feature = "use_heapless " ) ]
244
+ #[ cfg( feature = "heapless " ) ]
245
245
result. push ( data_package) . ok ( ) ;
246
- #[ cfg( feature = "use_heapless " ) ]
246
+ #[ cfg( feature = "heapless " ) ]
247
247
if result. len ( ) == MAX_RESULTS {
248
248
return result;
249
249
}
@@ -399,9 +399,9 @@ mod tests {
399
399
#[ test]
400
400
fn test_parse ( ) {
401
401
let input = b"\x00 !B11:!B10;\x00 \x00 !\x00 \x00 \x00 \x00 !B138" ;
402
- #[ cfg( feature = "use_heapless " ) ]
402
+ #[ cfg( feature = "heapless " ) ]
403
403
let result = parse :: < 4 > ( input) ;
404
- #[ cfg( feature = "use_alloc " ) ]
404
+ #[ cfg( feature = "alloc " ) ]
405
405
let result = parse ( input) ;
406
406
407
407
assert_eq ! ( result. len( ) , 4 ) ;
@@ -413,7 +413,7 @@ mod tests {
413
413
e,
414
414
& ProtocolParseError :: ButtonParseError ( ButtonParseError :: UnknownButtonState ( b'3' ) )
415
415
) ;
416
- #[ cfg( feature = "use_alloc " ) ]
416
+ #[ cfg( feature = "alloc " ) ]
417
417
{
418
418
use alloc:: string:: ToString ;
419
419
use core:: error:: Error ;
0 commit comments