From 4b6516fa2389b95e3a748bf0530c4474830cbea1 Mon Sep 17 00:00:00 2001 From: Folyd Date: Mon, 8 Mar 2021 03:14:52 +0800 Subject: [PATCH] Replace the Into implement to From for Recipient and WeakRecipient (#479) According to the [C-CONV-TRAITS](https://rust-lang.github.io/api-guidelines/interoperability.html#c-conv-traits) of Rust API Guidelines, The following conversion traits should never be implemented: - `Into` - `TryInto` These traits have a blanket impl based on `From` and `TryFrom`. Implement those instead. --- actix/CHANGES.md | 2 ++ actix/src/address/mod.rs | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/actix/CHANGES.md b/actix/CHANGES.md index 96f5e2dd..13e4923c 100644 --- a/actix/CHANGES.md +++ b/actix/CHANGES.md @@ -5,8 +5,10 @@ * Remove `fut::IntoActorFuture` trait. [#475] * Remove `fut::future::WrapFuture`'s `Output` associated type. [#475] * Remove `fut::stream::WrapStream`'s `Item` associated type. [#475] +* Replace the `Into` implementation to `From` for `Recipient` and `WeakRecipient`. [#479] [#475]: https://github.com/actix/actix/pull/475 +[#479]: https://github.com/actix/actix/pull/479 ## 0.11.0-beta.3 - 2021-03-03 diff --git a/actix/src/address/mod.rs b/actix/src/address/mod.rs index faa55f00..1b261d1e 100644 --- a/actix/src/address/mod.rs +++ b/actix/src/address/mod.rs @@ -282,14 +282,14 @@ where } } -impl Into> for Addr +impl From> for Recipient where A: Handler, M::Result: Send, A::Context: ToEnvelope, { - fn into(self) -> Recipient { - Recipient::new(Box::new(self.tx)) + fn from(addr: Addr) -> Self { + Recipient::new(Box::new(addr.tx)) } } @@ -376,25 +376,25 @@ where } } -impl Into> for Addr +impl From> for WeakRecipient where A: Handler, M::Result: Send, A::Context: ToEnvelope, { - fn into(self) -> WeakRecipient { - self.downgrade().recipient() + fn from(addr: Addr) -> WeakRecipient { + addr.downgrade().recipient() } } -impl Into> for WeakAddr +impl From> for WeakRecipient where A: Handler, M::Result: Send, A::Context: ToEnvelope, { - fn into(self) -> WeakRecipient { - WeakRecipient::new(Box::new(self.wtx)) + fn from(addr: WeakAddr) -> WeakRecipient { + WeakRecipient::new(Box::new(addr.wtx)) } }