@@ -29,35 +29,37 @@ pub struct AstCodegenResult {
2929 pub outputs : Vec < SideEffect > ,
3030}
3131
32- pub struct SideEffect ( /* path */ pub PathBuf , /* output */ pub Vec < u8 > ) ;
32+ pub struct SideEffect {
33+ pub path : PathBuf ,
34+ pub content : Vec < u8 > ,
35+ }
3336
3437impl SideEffect {
3538 /// Apply the side-effect
3639 pub fn apply ( self ) -> std:: io:: Result < ( ) > {
37- let Self ( path, data ) = self ;
40+ let Self { path, content } = self ;
3841 let path = path. into_os_string ( ) ;
3942 let path = path. to_str ( ) . unwrap ( ) ;
40- write_all_to ( & data , path) ?;
43+ write_all_to ( & content , path) ?;
4144 Ok ( ( ) )
4245 }
4346
4447 pub fn path ( & self ) -> String {
45- let Self ( path, _) = self ;
46- let path = path. to_string_lossy ( ) ;
48+ let path = self . path . to_string_lossy ( ) ;
4749 path. replace ( '\\' , "/" )
4850 }
4951}
5052
5153impl From < ( PathBuf , TokenStream ) > for SideEffect {
5254 fn from ( ( path, stream) : ( PathBuf , TokenStream ) ) -> Self {
5355 let content = pretty_print ( & stream) ;
54- Self ( path, content. as_bytes ( ) . into ( ) )
56+ Self { path, content : content . into ( ) }
5557 }
5658}
5759
5860impl From < GeneratorOutput > for SideEffect {
5961 fn from ( output : GeneratorOutput ) -> Self {
60- Self :: from ( ( output. 0 , output. 1 ) )
62+ Self :: from ( ( output. path , output. tokens ) )
6163 }
6264}
6365
0 commit comments