3131 let ( pos, val) = ( self . raw_parser ) ( pos, ctx) ?;
3232 let Some ( val) = f ( val) else {
3333 return Err ( ParseError {
34- source : ctx. source . iter ( ) . collect ( ) ,
34+ source : ctx. clone_source ( ) ,
3535 pos,
3636 reason : String :: from ( "try map failed: got None" ) ,
3737 } ) ;
@@ -110,7 +110,7 @@ where
110110 let ( pos, val) = self . parse ( pos, ctx) ?;
111111 match ctx. source . get ( pos) {
112112 Some ( c) => Err ( ParseError {
113- source : ctx. source . iter ( ) . collect ( ) ,
113+ source : ctx. clone_source ( ) ,
114114 pos,
115115 reason : format ! ( "expected EOF found {}" , c) ,
116116 } ) ,
@@ -129,12 +129,12 @@ pub fn satisfy(name: impl Into<String>, f: impl Fn(char) -> bool + 'static) -> P
129129 Rc :: new ( move |pos, ctx : & mut Context | match ctx. source . get ( pos) {
130130 Some ( & c) if f ( c) => Ok ( ( pos + 1 , c) ) ,
131131 Some ( c) => Err ( ParseError {
132- source : ctx. source . iter ( ) . collect ( ) ,
132+ source : ctx. clone_source ( ) ,
133133 pos,
134134 reason : format ! ( "expected {} got {}" , name, c) ,
135135 } ) ,
136136 None => Err ( ParseError {
137- source : ctx. source . iter ( ) . collect ( ) ,
137+ source : ctx. clone_source ( ) ,
138138 pos,
139139 reason : format ! ( "expected {} got EOF" , name) ,
140140 } ) ,
@@ -166,7 +166,7 @@ pub fn keyword(keyword: impl Into<String>) -> Parser<String> {
166166 Ok ( ( pos + keyword. len ( ) , name. clone ( ) ) )
167167 } else {
168168 Err ( ParseError {
169- source : ctx. source . iter ( ) . collect ( ) ,
169+ source : ctx. clone_source ( ) ,
170170 pos,
171171 reason : String :: from ( "" ) ,
172172 } )
0 commit comments