Browse Source

Merge #721

721: Make `AnySocket` object safe r=Dirbaio a=tsoutsman

Apologies, in #718, removing the sized bound in `downcast` and `downcast_mut` implicitly made `AnySocket` object unsafe as they don't have a `self` method. I had a bit of a brain fart.

Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>

Co-authored-by: Klim Tsoutsman <klim@tsoutsman.com>
bors[bot] 2 years ago
parent
commit
769630f3cd
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/socket/mod.rs

+ 6 - 2
src/socket/mod.rs

@@ -93,8 +93,12 @@ impl<'a> Socket<'a> {
 /// A conversion trait for network sockets.
 pub trait AnySocket<'a> {
     fn upcast(self) -> Socket<'a>;
-    fn downcast<'c>(socket: &'c Socket<'a>) -> Option<&'c Self>;
-    fn downcast_mut<'c>(socket: &'c mut Socket<'a>) -> Option<&'c mut Self>;
+    fn downcast<'c>(socket: &'c Socket<'a>) -> Option<&'c Self>
+    where
+        Self: Sized;
+    fn downcast_mut<'c>(socket: &'c mut Socket<'a>) -> Option<&'c mut Self>
+    where
+        Self: Sized;
 }
 
 macro_rules! from_socket {