@@ -47,7 +47,12 @@ impl Clock {
4747
4848impl fmt:: Display for Clock {
4949 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
50- write ! ( f, "{}ms ({:.1}Hz)" , self . base_period_ms, self . frequency_hz( ) )
50+ write ! (
51+ f,
52+ "{}ms ({:.1}Hz)" ,
53+ self . base_period_ms,
54+ self . frequency_hz( )
55+ )
5156 }
5257}
5358
@@ -152,7 +157,10 @@ impl std::str::FromStr for SignalType {
152157 "int" | "int32" | "integer" => Ok ( Self :: Int ) ,
153158 "float" | "f32" => Ok ( Self :: Float ) ,
154159 "real" | "double" | "f64" => Ok ( Self :: Real ) ,
155- other => Err ( format ! ( "Unknown signal type: '{}'. Expected bool, int, float, or real." , other) ) ,
160+ other => Err ( format ! (
161+ "Unknown signal type: '{}'. Expected bool, int, float, or real." ,
162+ other
163+ ) ) ,
156164 }
157165 }
158166}
@@ -261,23 +269,37 @@ impl LustreNode {
261269 errors. push ( "Node name must not be empty" . to_string ( ) ) ;
262270 }
263271
264- if !self . name . chars ( ) . next ( ) . map_or ( false , |c| c. is_ascii_alphabetic ( ) || c == '_' ) {
265- errors. push ( format ! ( "Node name '{}' must start with a letter or underscore" , self . name) ) ;
272+ if !self
273+ . name
274+ . chars ( )
275+ . next ( )
276+ . is_some_and ( |c| c. is_ascii_alphabetic ( ) || c == '_' )
277+ {
278+ errors. push ( format ! (
279+ "Node name '{}' must start with a letter or underscore" ,
280+ self . name
281+ ) ) ;
266282 }
267283
268284 if self . inputs . is_empty ( ) {
269285 errors. push ( format ! ( "Node '{}' must have at least one input" , self . name) ) ;
270286 }
271287
272288 if self . outputs . is_empty ( ) {
273- errors. push ( format ! ( "Node '{}' must have at least one output" , self . name) ) ;
289+ errors. push ( format ! (
290+ "Node '{}' must have at least one output" ,
291+ self . name
292+ ) ) ;
274293 }
275294
276295 // Check for duplicate signal names across inputs and outputs.
277296 let mut seen = std:: collections:: HashSet :: new ( ) ;
278297 for sig in self . inputs . iter ( ) . chain ( self . outputs . iter ( ) ) {
279298 if !seen. insert ( & sig. name ) {
280- errors. push ( format ! ( "Duplicate signal name '{}' in node '{}'" , sig. name, self . name) ) ;
299+ errors. push ( format ! (
300+ "Duplicate signal name '{}' in node '{}'" ,
301+ sig. name, self . name
302+ ) ) ;
281303 }
282304 }
283305
@@ -406,7 +428,12 @@ impl EmbeddedTarget {
406428 /// Return recommended compiler optimisation flags for this target.
407429 pub fn compiler_flags ( & self ) -> & ' static [ & ' static str ] {
408430 match self {
409- Self :: ArmCortexM => & [ "-mcpu=cortex-m4" , "-mthumb" , "-mfloat-abi=hard" , "-mfpu=fpv4-sp-d16" ] ,
431+ Self :: ArmCortexM => & [
432+ "-mcpu=cortex-m4" ,
433+ "-mthumb" ,
434+ "-mfloat-abi=hard" ,
435+ "-mfpu=fpv4-sp-d16" ,
436+ ] ,
410437 Self :: RiscV => & [ "-march=rv32imac" , "-mabi=ilp32" ] ,
411438 Self :: X86 => & [ "-march=native" , "-O2" ] ,
412439 }
@@ -456,7 +483,12 @@ pub struct Wcet {
456483
457484impl Wcet {
458485 /// Create a new WCET result.
459- pub fn new ( node_name : impl Into < String > , estimated_us : u64 , deadline_us : u64 , analysis_performed : bool ) -> Self {
486+ pub fn new (
487+ node_name : impl Into < String > ,
488+ estimated_us : u64 ,
489+ deadline_us : u64 ,
490+ analysis_performed : bool ,
491+ ) -> Self {
460492 Self {
461493 node_name : node_name. into ( ) ,
462494 estimated_us,
@@ -496,7 +528,11 @@ impl Wcet {
496528
497529impl fmt:: Display for Wcet {
498530 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
499- let status = if self . meets_deadline ( ) { "OK" } else { "VIOLATION" } ;
531+ let status = if self . meets_deadline ( ) {
532+ "OK"
533+ } else {
534+ "VIOLATION"
535+ } ;
500536 write ! (
501537 f,
502538 "WCET({}) = {}us / {}us deadline [{}] (utilisation: {:.1}%)" ,
@@ -561,16 +597,34 @@ mod tests {
561597
562598 #[ test]
563599 fn test_safety_standard_parsing ( ) {
564- assert_eq ! ( "DO-178C" . parse:: <SafetyStandard >( ) . unwrap( ) , SafetyStandard :: Do178c ) ;
565- assert_eq ! ( "IEC-61508" . parse:: <SafetyStandard >( ) . unwrap( ) , SafetyStandard :: Iec61508 ) ;
566- assert_eq ! ( "ISO-26262" . parse:: <SafetyStandard >( ) . unwrap( ) , SafetyStandard :: Iso26262 ) ;
600+ assert_eq ! (
601+ "DO-178C" . parse:: <SafetyStandard >( ) . unwrap( ) ,
602+ SafetyStandard :: Do178c
603+ ) ;
604+ assert_eq ! (
605+ "IEC-61508" . parse:: <SafetyStandard >( ) . unwrap( ) ,
606+ SafetyStandard :: Iec61508
607+ ) ;
608+ assert_eq ! (
609+ "ISO-26262" . parse:: <SafetyStandard >( ) . unwrap( ) ,
610+ SafetyStandard :: Iso26262
611+ ) ;
567612 }
568613
569614 #[ test]
570615 fn test_embedded_target_parsing ( ) {
571- assert_eq ! ( "arm-cortex-m" . parse:: <EmbeddedTarget >( ) . unwrap( ) , EmbeddedTarget :: ArmCortexM ) ;
572- assert_eq ! ( "riscv" . parse:: <EmbeddedTarget >( ) . unwrap( ) , EmbeddedTarget :: RiscV ) ;
573- assert_eq ! ( "x86" . parse:: <EmbeddedTarget >( ) . unwrap( ) , EmbeddedTarget :: X86 ) ;
616+ assert_eq ! (
617+ "arm-cortex-m" . parse:: <EmbeddedTarget >( ) . unwrap( ) ,
618+ EmbeddedTarget :: ArmCortexM
619+ ) ;
620+ assert_eq ! (
621+ "riscv" . parse:: <EmbeddedTarget >( ) . unwrap( ) ,
622+ EmbeddedTarget :: RiscV
623+ ) ;
624+ assert_eq ! (
625+ "x86" . parse:: <EmbeddedTarget >( ) . unwrap( ) ,
626+ EmbeddedTarget :: X86
627+ ) ;
574628 }
575629
576630 #[ test]
@@ -589,9 +643,9 @@ mod tests {
589643 fn test_wcet_safety_standard_compliance ( ) {
590644 // 70% utilisation => 30% margin => passes all standards
591645 let w = Wcet :: new ( "ctrl" , 700 , 1000 , true ) ;
592- assert ! ( w. satisfies_standard( & SafetyStandard :: Iso26262 ) ) ; // needs 20%
593- assert ! ( w. satisfies_standard( & SafetyStandard :: Iec61508 ) ) ; // needs 15%
594- assert ! ( w. satisfies_standard( & SafetyStandard :: Do178c ) ) ; // needs 10%
646+ assert ! ( w. satisfies_standard( & SafetyStandard :: Iso26262 ) ) ; // needs 20%
647+ assert ! ( w. satisfies_standard( & SafetyStandard :: Iec61508 ) ) ; // needs 15%
648+ assert ! ( w. satisfies_standard( & SafetyStandard :: Do178c ) ) ; // needs 10%
595649
596650 // 95% utilisation => 5% margin => fails all
597651 let w_tight = Wcet :: new ( "ctrl" , 950 , 1000 , true ) ;
@@ -604,15 +658,30 @@ mod tests {
604658 fn test_temporal_operator_display ( ) {
605659 assert_eq ! ( format!( "{}" , TemporalOperator :: Pre ) , "pre" ) ;
606660 assert_eq ! (
607- format!( "{}" , TemporalOperator :: Fby { init_expr: "0" . to_string( ) } ) ,
661+ format!(
662+ "{}" ,
663+ TemporalOperator :: Fby {
664+ init_expr: "0" . to_string( )
665+ }
666+ ) ,
608667 "0 fby"
609668 ) ;
610669 assert_eq ! (
611- format!( "{}" , TemporalOperator :: When { clock_signal: "clk_10hz" . to_string( ) } ) ,
670+ format!(
671+ "{}" ,
672+ TemporalOperator :: When {
673+ clock_signal: "clk_10hz" . to_string( )
674+ }
675+ ) ,
612676 "when clk_10hz"
613677 ) ;
614678 assert_eq ! (
615- format!( "{}" , TemporalOperator :: Merge { clock_signal: "sel" . to_string( ) } ) ,
679+ format!(
680+ "{}" ,
681+ TemporalOperator :: Merge {
682+ clock_signal: "sel" . to_string( )
683+ }
684+ ) ,
616685 "merge(sel)"
617686 ) ;
618687 }
0 commit comments