File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -422,6 +422,26 @@ fn default_value_const() {
422422 assert_eq ! ( t. raw_value, 0xBADCAFE ) ;
423423}
424424
425+ #[ test]
426+ fn builder_available_in_const_context ( ) {
427+ #[ bitfield( u16 ) ]
428+ #[ derive( Debug ) ]
429+ pub struct Test {
430+ #[ bits( 0 ..=15 , rw) ]
431+ a : u16 ,
432+ }
433+
434+ assert_eq ! ( const { Test :: builder( ) . with_a( 123 ) . build( ) . raw_value( ) } , 123 ) ;
435+ const {
436+ let raw = Test :: builder ( ) . with_a ( 123 ) . build ( ) . raw_value ( ) ;
437+ if raw != 123 {
438+ panic ! ( "builder didn't build the right value `123`" ) ;
439+ }
440+ }
441+ const TEST : Test = Test :: builder ( ) . with_a ( 123 ) . build ( ) ;
442+ assert_eq ! ( TEST . raw_value( ) , 123 ) ;
443+ }
444+
425445#[ test]
426446fn more_struct_attributes ( ) {
427447 // Test that other attributes can be appended
You can’t perform that action at this time.
0 commit comments