@@ -332,7 +332,7 @@ impl RenderablePredicate<'_> {
332332}
333333
334334/// Intermediate representation used in the display process.
335- struct RenderableTypingRule < ' a > {
335+ pub ( crate ) struct RenderableTypingRule < ' a > {
336336 name : Rule ,
337337 preconditions : Vec < RenderablePredicate < ' a > > ,
338338 postconditions : Vec < RenderablePredicate < ' a > > ,
@@ -348,7 +348,7 @@ impl<'a> TypingRule<'a> {
348348 cstrs
349349 }
350350
351- fn make_renderable (
351+ pub ( crate ) fn make_renderable (
352352 & ' a self ,
353353 _a : & ' a Arenas < ' a > ,
354354 style : PredicateStyle ,
@@ -442,12 +442,26 @@ impl<'a> TypingRule<'a> {
442442
443443 pub fn display ( & self , style : PredicateStyle ) -> Result < String , IncompatibleStyle > {
444444 let a = & Arenas :: default ( ) ;
445- self . make_renderable ( a, style) ?. display ( style)
445+ Ok ( self . make_renderable ( a, style) ?. display ( style) )
446446 }
447447}
448448
449449impl < ' a > RenderableTypingRule < ' a > {
450- pub fn display ( & self , style : PredicateStyle ) -> Result < String , IncompatibleStyle > {
450+ pub fn display ( & self , style : PredicateStyle ) -> String {
451+ Self :: assemble_pieces ( self . display_piecewise ( style) )
452+ }
453+
454+ pub fn assemble_pieces (
455+ [ preconditions_str, bar, name, postconditions_str] : [ String ; 4 ] ,
456+ ) -> String {
457+ let mut out = String :: new ( ) ;
458+ let _ = write ! ( & mut out, "{preconditions_str}\n " ) ;
459+ let _ = write ! ( & mut out, "{bar} \" {name}\" \n " ) ;
460+ let _ = write ! ( & mut out, "{postconditions_str}" ) ;
461+ out
462+ }
463+
464+ pub fn display_piecewise ( & self , style : PredicateStyle ) -> [ String ; 4 ] {
451465 let postconditions_str = self
452466 . postconditions
453467 . iter ( )
@@ -487,11 +501,8 @@ impl<'a> RenderableTypingRule<'a> {
487501 display_len ( & postconditions_str) ,
488502 ) ;
489503 let bar = "-" . repeat ( len) ;
490- let mut out = String :: new ( ) ;
491- let _ = write ! ( & mut out, "{preconditions_str}\n " ) ;
492- let _ = write ! ( & mut out, "{bar} \" {}\" \n " , self . name. display( self . options) ) ;
493- let _ = write ! ( & mut out, "{postconditions_str}" ) ;
494- Ok ( out)
504+ let name = self . name . display ( self . options ) ;
505+ [ preconditions_str, bar, name, postconditions_str]
495506 }
496507}
497508
0 commit comments