@@ -57,7 +57,8 @@ impl<T: ?Sized, U> Captures<U> for T {}
57
57
#[ allow( clippy:: too_many_lines) ]
58
58
pub fn muropeptide < ' z , ' a , ' p , ' s > (
59
59
polymerizer : & ' z Polymerizer < ' a , ' p > ,
60
- ) -> impl FnMut ( & ' s str ) -> ParseResult < Muropeptide < ' a , ' p > > + Captures < ( & ' z ( ) , & ' a ( ) , & ' p ( ) ) > {
60
+ ) -> impl FnMut ( & ' s str ) -> ParseResult < ' s , Muropeptide < ' a , ' p > > + Captures < ( & ' z ( ) , & ' a ( ) , & ' p ( ) ) >
61
+ {
61
62
move |i| {
62
63
let polymer = RefCell :: new ( polymerizer. new_polymer ( ) ) ;
63
64
// FIXME: Perhaps there is a better way to shorten that `polymer` borrow...
@@ -222,7 +223,7 @@ pub fn muropeptide<'z, 'a, 'p, 's>(
222
223
// FIXME: Make private again
223
224
pub fn monomer < ' c , ' a , ' p , ' s > (
224
225
polymer : & ' c RefCell < Polymer < ' a , ' p > > ,
225
- ) -> impl FnMut ( & ' s str ) -> ParseResult < Monomer > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
226
+ ) -> impl FnMut ( & ' s str ) -> ParseResult < ' s , Monomer > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
226
227
let optional_peptide = opt ( preceded ( char ( '-' ) , cut ( peptide ( polymer) ) ) ) ;
227
228
let glycan_and_peptide = map_res (
228
229
pair ( glycan ( polymer) , optional_peptide) ,
@@ -260,7 +261,8 @@ pub fn monomer<'c, 'a, 'p, 's>(
260
261
/// Glycan = { Monosaccharide }- ;
261
262
fn glycan < ' c , ' a , ' p , ' s > (
262
263
polymer : & ' c RefCell < Polymer < ' a , ' p > > ,
263
- ) -> impl FnMut ( & ' s str ) -> ParseResult < Vec < Monosaccharide > > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
264
+ ) -> impl FnMut ( & ' s str ) -> ParseResult < ' s , Vec < Monosaccharide > > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) >
265
+ {
264
266
let parser = many1 ( monosaccharide ( polymer) ) ;
265
267
map_res ( parser, |residues| {
266
268
polymer
@@ -273,7 +275,7 @@ fn glycan<'c, 'a, 'p, 's>(
273
275
/// Peptide = { Amino Acid }- ;
274
276
fn peptide < ' c , ' a , ' p , ' s > (
275
277
polymer : & ' c RefCell < Polymer < ' a , ' p > > ,
276
- ) -> impl FnMut ( & ' s str ) -> ParseResult < Vec < AminoAcid > > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
278
+ ) -> impl FnMut ( & ' s str ) -> ParseResult < ' s , Vec < AminoAcid > > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
277
279
let parser = many1 ( amino_acid ( polymer) ) ;
278
280
map_res ( parser, |residues| {
279
281
let residue_ids = residues. iter ( ) . map ( |aa| aa. residue ) ;
@@ -287,7 +289,7 @@ fn peptide<'c, 'a, 'p, 's>(
287
289
/// Monosaccharide = lowercase , [ Modifications ] ;
288
290
fn monosaccharide < ' c , ' a , ' p , ' s > (
289
291
polymer : & ' c RefCell < Polymer < ' a , ' p > > ,
290
- ) -> impl FnMut ( & ' s str ) -> ParseResult < Monosaccharide > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
292
+ ) -> impl FnMut ( & ' s str ) -> ParseResult < ' s , Monosaccharide > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
291
293
let parser = pair ( recognize ( lowercase) , opt ( modifications ( polymer) ) ) ;
292
294
map_res ( parser, |( abbr, modifications) | {
293
295
let residue = polymer. borrow_mut ( ) . new_residue ( abbr) ?;
@@ -305,7 +307,7 @@ fn monosaccharide<'c, 'a, 'p, 's>(
305
307
/// Amino Acid = Unbranched Amino Acid , [ Lateral Chain ] ;
306
308
fn amino_acid < ' c , ' a , ' p , ' s > (
307
309
polymer : & ' c RefCell < Polymer < ' a , ' p > > ,
308
- ) -> impl FnMut ( & ' s str ) -> ParseResult < AminoAcid > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
310
+ ) -> impl FnMut ( & ' s str ) -> ParseResult < ' s , AminoAcid > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
309
311
let parser = pair ( unbranched_amino_acid ( polymer) , opt ( lateral_chain ( polymer) ) ) ;
310
312
map_res ( parser, |( residue, lateral_chain) | {
311
313
if let Some ( LateralChain { direction, peptide } ) = & lateral_chain {
@@ -349,7 +351,8 @@ fn amino_acid<'c, 'a, 'p, 's>(
349
351
/// { { " " } , "," , { " " } , Any Modification } , ")" ;
350
352
fn modifications < ' c , ' a , ' p , ' s > (
351
353
polymer : & ' c RefCell < Polymer < ' a , ' p > > ,
352
- ) -> impl FnMut ( & ' s str ) -> ParseResult < Vec < ModificationId > > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
354
+ ) -> impl FnMut ( & ' s str ) -> ParseResult < ' s , Vec < ModificationId > > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) >
355
+ {
353
356
let separator = delimited ( space0, char ( ',' ) , space0) ;
354
357
delimited (
355
358
char ( '(' ) ,
@@ -361,7 +364,8 @@ fn modifications<'c, 'a, 'p, 's>(
361
364
/// Unbranched Amino Acid = [ lowercase ] , uppercase , [ Modifications ] ;
362
365
fn unbranched_amino_acid < ' c , ' a , ' p , ' s > (
363
366
polymer : & ' c RefCell < Polymer < ' a , ' p > > ,
364
- ) -> impl FnMut ( & ' s str ) -> ParseResult < UnbranchedAminoAcid > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
367
+ ) -> impl FnMut ( & ' s str ) -> ParseResult < ' s , UnbranchedAminoAcid > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) >
368
+ {
365
369
let abbr = recognize ( preceded ( opt ( lowercase) , uppercase) ) ;
366
370
let parser = pair ( abbr, opt ( modifications ( polymer) ) ) ;
367
371
map_res ( parser, |( abbr, modifications) | {
@@ -381,7 +385,7 @@ fn unbranched_amino_acid<'c, 'a, 'p, 's>(
381
385
/// Lateral Chain = "[" , Peptide Direction , { Unbranched Amino Acid }- , "]" ;
382
386
fn lateral_chain < ' c , ' a , ' p , ' s > (
383
387
polymer : & ' c RefCell < Polymer < ' a , ' p > > ,
384
- ) -> impl FnMut ( & ' s str ) -> ParseResult < LateralChain > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
388
+ ) -> impl FnMut ( & ' s str ) -> ParseResult < ' s , LateralChain > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
385
389
let peptide = many1 ( unbranched_amino_acid ( polymer) ) ;
386
390
let parser = delimited ( char ( '[' ) , peptide, char ( ']' ) ) ;
387
391
map ( parser, |peptide| LateralChain {
@@ -413,15 +417,15 @@ fn identifier(i: &str) -> ParseResult<&str> {
413
417
/// Any Modification = Named Modification | Offset Modification
414
418
pub fn any_modification < ' c , ' a , ' p , ' s > (
415
419
polymer : & ' c RefCell < Polymer < ' a , ' p > > ,
416
- ) -> impl FnMut ( & ' s str ) -> ParseResult < ModificationId > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
420
+ ) -> impl FnMut ( & ' s str ) -> ParseResult < ' s , ModificationId > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
417
421
alt ( ( named_modification ( polymer) , offset_modification ( polymer) ) )
418
422
}
419
423
420
424
// FIXME: I probably need to add a lot of `wrap_err`s around these parsers!
421
425
/// Named Modification = [ Multiplier ] , Identifier
422
426
pub fn named_modification < ' c , ' a , ' p , ' s > (
423
427
polymer : & ' c RefCell < Polymer < ' a , ' p > > ,
424
- ) -> impl FnMut ( & ' s str ) -> ParseResult < ModificationId > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
428
+ ) -> impl FnMut ( & ' s str ) -> ParseResult < ' s , ModificationId > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
425
429
let parser = pair ( opt ( multiplier) , identifier) ;
426
430
map_res ( parser, |( multiplier, named_mod) | {
427
431
polymer
@@ -435,7 +439,7 @@ pub fn named_modification<'c, 'a, 'p, 's>(
435
439
/// Chemical Composition ;
436
440
pub fn offset_modification < ' c , ' a , ' p , ' s > (
437
441
polymer : & ' c RefCell < Polymer < ' a , ' p > > ,
438
- ) -> impl FnMut ( & ' s str ) -> ParseResult < ModificationId > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
442
+ ) -> impl FnMut ( & ' s str ) -> ParseResult < ' s , ModificationId > + Captures < ( & ' c ( ) , & ' a ( ) , & ' p ( ) ) > {
439
443
let chemical_composition = chemical_composition ( polymer. borrow ( ) . atomic_db ( ) ) ;
440
444
let parser = tuple ( ( offset_kind, opt ( multiplier) , chemical_composition) ) ;
441
445
0 commit comments