chiark / gitweb /
rm crap
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 5 Jun 2023 16:32:04 +0000 (17:32 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 5 Jun 2023 16:32:04 +0000 (17:32 +0100)
src/main.rs

index 67878f6f0ee27c2994899b2be340d871b0f8b9f8..a622907197df391ec52655c3c3b8d2a283efaac2 100644 (file)
@@ -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<T: 'static>(&self) -> Option<Box<T>>;
-}
-
-impl<T:HasPseudoMethods+?Sized> HasPseudoMethodsExt for T {
-    fn cast_to<U: 'static>(&self) -> Option<Box<U>> {
-           let instance = self.cast_to_instance(TypeId::of::<U>())?;
-           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<dyn Any + Send + Sync> = DowncastSync::into_any_arc(arc.clone());
-           let arc: Arc<Frog> = Arc::downcast::<Frog>(arc).unwrap();
-           let arc: Arc<dyn HasFeet> = 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::<Arc<dyn EatsFood>>() {
-           let arc: Arc<dyn EatsFood> = self.clone();
-           return Some(Box::new(arc));
-*/
        }
        None
     }