make SingularRobust default
	
		
			
	
		
	
	
				
					
				
			This commit is contained in:
		
							parent
							
								
									0814215594
								
							
						
					
					
						commit
						e8c2ec739d
					
				@ -21,10 +21,6 @@ pub struct SingularResolver<'a, Ctx: Context<'a>> {
 | 
				
			|||||||
    points: Vec<Arc<dyn SingularResolution<'a, Ctx>>>,
 | 
					    points: Vec<Arc<dyn SingularResolution<'a, Ctx>>>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct SingularRobust<'a, Ctx: Context<'a>> {
 | 
					 | 
				
			||||||
    resolver: Arc<SingularResolver<'a, Ctx>>,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl<'a, Ctx: Context<'a>> SingularResolver<'a, Ctx> {
 | 
					impl<'a, Ctx: Context<'a>> SingularResolver<'a, Ctx> {
 | 
				
			||||||
    pub fn from_mentionable<A: Mentionable<'a, Ctx>>(a: &A) -> Self {
 | 
					    pub fn from_mentionable<A: Mentionable<'a, Ctx>>(a: &A) -> Self {
 | 
				
			||||||
        let mut points = Vec::new();
 | 
					        let mut points = Vec::new();
 | 
				
			||||||
@ -53,26 +49,11 @@ impl<'a, Ctx: Context<'a>> SingularResolver<'a, Ctx> {
 | 
				
			|||||||
            Ok(point.clone().singular())
 | 
					            Ok(point.clone().singular())
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    pub fn robust(self) -> Arc<dyn Resolver<'a, Ctx>> {
 | 
					 | 
				
			||||||
        SingularRobust {
 | 
					 | 
				
			||||||
            resolver: self.into(),
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        .into_rc()
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<'a, Ctx: Context<'a>> Resolver<'a, Ctx> for SingularResolver<'a, Ctx> {
 | 
					impl<'a, Ctx: Context<'a>> Resolver<'a, Ctx> for SingularResolver<'a, Ctx> {
 | 
				
			||||||
    fn resolve(self: Arc<Self>, address: Address) -> HashResolution<'a, Ctx> {
 | 
					    fn resolve(self: Arc<Self>, address: Address) -> HashResolution<'a, Ctx> {
 | 
				
			||||||
        self.resolve_robust(address).unwrap()
 | 
					        self.resolve_robust(address)
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl<'a, Ctx: Context<'a>> Resolver<'a, Ctx> for SingularRobust<'a, Ctx> {
 | 
					 | 
				
			||||||
    fn resolve(self: Arc<Self>, address: Address) -> HashResolution<'a, Ctx> {
 | 
					 | 
				
			||||||
        self.resolver
 | 
					 | 
				
			||||||
            .clone()
 | 
					 | 
				
			||||||
            .resolve_robust(address)
 | 
					 | 
				
			||||||
            .map_err(SingularError::into)
 | 
					            .map_err(SingularError::into)
 | 
				
			||||||
            .map_err(Err)
 | 
					            .map_err(Err)
 | 
				
			||||||
            .unwrap_or_else(Ctx::pure)
 | 
					            .unwrap_or_else(Ctx::pure)
 | 
				
			||||||
 | 
				
			|||||||
@ -8,7 +8,7 @@ pub trait CastMentionable<'a, Ctx: Context<'a>>: Mentionable<'a, Ctx> {
 | 
				
			|||||||
    fn m_cast<A: Mentionable<'a, Ctx>>(&self, factory: &Fctr<'a, A>) -> ParseResultA<'a, A> {
 | 
					    fn m_cast<A: Mentionable<'a, Ctx>>(&self, factory: &Fctr<'a, A>) -> ParseResultA<'a, A> {
 | 
				
			||||||
        factory.parse_slice(
 | 
					        factory.parse_slice(
 | 
				
			||||||
            &self.bytes(),
 | 
					            &self.bytes(),
 | 
				
			||||||
            &SingularResolver::from_mentionable(self).robust(),
 | 
					            &SingularResolver::from_mentionable(self).into_rc(),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user