File tree Expand file tree Collapse file tree 2 files changed +20
-10
lines changed
Expand file tree Collapse file tree 2 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -57,11 +57,14 @@ impl FilesystemInclude {
5757
5858impl Include for FilesystemInclude {
5959 fn include ( & self , relative_path : & str ) -> Result < String > {
60- let root =
61- self . root
62- . canonicalize ( )
63- . chain ( "Snippet does not exist" )
64- . context_with ( || ( "non-existent source" . into ( ) , self . root . to_string_lossy ( ) . into ( ) ) ) ?;
60+ let root = self . root
61+ . canonicalize ( )
62+ . chain ( "Snippet does not exist" )
63+ . context_with ( || {
64+ let key = "non-existent source" . into ( ) ;
65+ let value = self . root . to_string_lossy ( ) . into ( ) ;
66+ ( key, value)
67+ } ) ?;
6568 let mut path = root. clone ( ) ;
6669 path. extend ( relative_path. split ( '/' ) ) ;
6770 let path =
Original file line number Diff line number Diff line change @@ -157,13 +157,16 @@ pub fn granularize(block: &str) -> Result<Vec<Token>> {
157157 x if NUMBER_LITERAL . is_match ( x) => {
158158 x. parse :: < i32 > ( ) . map ( Token :: IntegerLiteral ) . unwrap_or_else (
159159 |_e| {
160- Token :: FloatLiteral ( x. parse :: < f32 > ( )
161- . expect ( "matches to NUMBER_LITERAL are parseable as floats" ) )
160+ let x = x. parse :: < f32 > ( )
161+ . expect ( "matches to NUMBER_LITERAL are parseable as floats" ) ;
162+ Token :: FloatLiteral ( x)
162163 } ,
163164 )
164165 }
165166 x if BOOLEAN_LITERAL . is_match ( x) => {
166- Token :: BooleanLiteral ( x. parse :: < bool > ( ) . expect ( "matches to BOOLEAN_LITERAL are parseable as bools" ) )
167+ Token :: BooleanLiteral ( x. parse :: < bool > ( ) . expect (
168+ "matches to BOOLEAN_LITERAL are parseable as bools" ,
169+ ) )
167170 }
168171 x if INDEX . is_match ( x) => {
169172 let mut parts = x. splitn ( 2 , '.' ) ;
@@ -172,8 +175,12 @@ pub fn granularize(block: &str) -> Result<Vec<Token>> {
172175 Token :: Dot
173176 }
174177 x if IDENTIFIER . is_match ( x) => Token :: Identifier ( x. to_owned ( ) ) ,
175- x => return Err ( Error :: with_msg ( "Invalid identifier" )
176- . context ( "identifier" , & x) ) ,
178+ x => {
179+ return Err ( Error :: with_msg ( "Invalid identifier" ) . context (
180+ "identifier" ,
181+ & x,
182+ ) )
183+ }
177184 } ) ;
178185 if let Some ( v) = push_more {
179186 result. extend ( v) ;
You can’t perform that action at this time.
0 commit comments