From 7cd50d155e8999c50e3c2fa905fca95a7441088f Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 5 Jun 2023 17:32:04 +0100 Subject: [PATCH] rm crap --- src/main.rs | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/src/main.rs b/src/main.rs index 67878f6..a622907 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,39 +8,17 @@ pub trait HasPseudoMethods: DowncastSync { fn get_caster(&self, tp: TypeId) -> Option<&'static dyn Any>; } impl_downcast!(sync HasPseudoMethods); -/* -pub trait HasPseudoMethodsExt { - fn cast_to(&self) -> Option>; -} - -impl HasPseudoMethodsExt for T { - fn cast_to(&self) -> Option> { - let instance = self.cast_to_instance(TypeId::of::())?; - instance.downcast().ok() - } -}*/ trait HasFeet { fn how_many_feet(&self) -> usize; } -trait EatsFood { - fn favorite_food(&self) -> &'static str; -} - struct Frog; impl HasFeet for Frog { fn how_many_feet(&self) -> usize { 4 } } -/* -impl EatsFood for Frog { - fn favorite_food(&self) -> &'static str { - "flies" - } -}*/ - impl HasPseudoMethods for Frog { // Note: if you wanted to be able to add more traits to Frog elsewhere, you would // need a registry of cast-to-trait objects, similar to the existing dispatch @@ -49,10 +27,6 @@ impl HasPseudoMethods for Frog { if tp == TypeId::of::< &'static dyn HasFeet >() { -/* let arc: Arc = DowncastSync::into_any_arc(arc.clone()); - let arc: Arc = Arc::downcast::(arc).unwrap(); - let arc: Arc = arc as _; - */ static CASTER: fn(&dyn HasPseudoMethods) -> &dyn HasFeet = |self_| { let self_: &dyn Any = Downcast::as_any(self_); @@ -62,10 +36,6 @@ impl HasPseudoMethods for Frog { }; return Some(&CASTER); -/* } else if tp == TypeId::of::>() { - let arc: Arc = self.clone(); - return Some(Box::new(arc)); -*/ } None } -- 2.30.2