[types] OMG SO MUCH LIFETIME NONSENSE
This commit is contained in:
		
							parent
							
								
									1e12508348
								
							
						
					
					
						commit
						576b81e52c
					
				
					 2 changed files with 9 additions and 7 deletions
				
			
		|  | @ -17,16 +17,18 @@ impl Number for Int { | |||
| } | ||||
| 
 | ||||
| impl PartialEq<Obj> for Int { | ||||
|     fn eq(&self, rhs: &Obj) -> bool { | ||||
|         match rhs.obj().and_then(Object::as_num) { | ||||
|     fn eq<'a>(&self, rhs: &'a Obj) -> bool { | ||||
|         let obj: Option<&'a Object> = rhs.obj(); | ||||
|         let num: Option<&'a Number> = obj.and_then(Object::as_num); | ||||
|         match num { | ||||
|             Some(num) => self == num, | ||||
|             None => false | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| impl PartialEq<Number> for Int { | ||||
|     fn eq(&self, rhs: &Number) -> bool { | ||||
| impl<'a> PartialEq<Number + 'a> for Int { | ||||
|     fn eq(&self, rhs: &(Number + 'a)) -> bool { | ||||
|         match rhs.as_int() { | ||||
|             Some(rhs) => *self == *rhs, | ||||
|             None => false | ||||
|  |  | |||
|  | @ -44,11 +44,11 @@ pub trait Object: | |||
| } | ||||
| 
 | ||||
| impl Obj { | ||||
|     pub fn new<T: 'static + Object>(obj: T) -> Obj { | ||||
|     pub fn new<T: Object + 'static>(obj: T) -> Obj { | ||||
|         Obj::Ptr(Box::new(obj)) | ||||
|     } | ||||
| 
 | ||||
|     pub fn obj<'a>(&'a self) -> Option<&'a Object> { | ||||
|     pub fn obj<'s, 'r: 's>(&'s self) -> Option<&'r (Object + 's)> { | ||||
|         match self { | ||||
|             Obj::Ptr(obj) => Some(obj.deref()), | ||||
|             Obj::Null => None | ||||
|  | @ -60,7 +60,7 @@ impl Obj { | |||
|         mem::replace(self, Obj::Null) | ||||
|     } | ||||
| 
 | ||||
|     pub fn unbox_as<T: 'static + Object>(&self) -> Option<&T> { | ||||
|     pub fn unbox_as<T: Object + 'static>(&self) -> Option<&T> { | ||||
|         match self { | ||||
|             Obj::Null => None, | ||||
|             Obj::Ptr(obj) => obj.as_any().downcast_ref::<T>() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue