Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1064093rwd; Thu, 25 May 2023 07:36:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4/H4HQb2Ny59MrYVLr+WSX/Oqxus8o9VeQBZSeg9KF96qdX1DLj6tCsSRdumH4oevQ1xZq X-Received: by 2002:a17:902:e5cc:b0:1ab:14f2:e7e6 with SMTP id u12-20020a170902e5cc00b001ab14f2e7e6mr2106850plf.65.1685025364507; Thu, 25 May 2023 07:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685025364; cv=none; d=google.com; s=arc-20160816; b=lITU2fURdtz5NVUbLWMNurkP5UnXon4qP5PR5skzpiv2TKvBxBln5RH59dCdesYOgw 51Qfulfhj71OODfajhTW9Bzn4/RiQ9jHwyMXcsXCzJWZW7O7bvGYOqp/bH+Oe/8jcgqC CTjS0IvA+t7zi2m6qnjUV+h3PECo85Q/v+nzlR8i7RMwR/BVx7iAdkIdrWWGRbbEc1Nz RL+ie7aiYR7DKZcIHgHfVj5++PFvQTRzRk/DPwqW0qTO5BgFbmFlCDJzGnszRlac/Zwa 1HtaG90HVN+1QqHgHJo8dX8yaSFilR2T4jsM1OOilP06VDZSfWj0oo+CBIHKMrtu02Xy MJww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:cc:from:to :dkim-signature:date; bh=6YZpbdH442xI5ahkra+Rj8DusW4wlxrFG6pdXqv769o=; b=DWVJKCim5YFeMZxmUpBwtngsnSix+JKzZzikjGZda/zKl4Ozxp6yjl45Fb5vXxvRxr m99SZWvBC7w0HJl4wFGG8kIP/zZSHoPJiD2XpgsLKZAHR8fMEfHbL5H8fOItECjdbLN9 RCEPG1tvklK2gJhZDwwd9+Xw+EOUEIoaimpKYQiSt3rEGxqUiIP/tYgVNgz5lleGyPM2 0w9S+3XANDE0merqLuFYRssB1IRF34kNW6Tw6Bj12bWhlNtBJmBwZRhnKF3Pa5K2Ny32 X7PPvDnRqWQQxsrBesuecgP1dZfJrPNY0MG7XGiU1QeWNAexZanNJW98/61cszyA0fjN JLnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@proton.me header.s=5aoyqs344fhubkfvtkwrcry4xi.protonmail header.b=cic8tsuM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020a1709028ec500b001a6ee332903si1487000plo.347.2023.05.25.07.35.49; Thu, 25 May 2023 07:36:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=5aoyqs344fhubkfvtkwrcry4xi.protonmail header.b=cic8tsuM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241395AbjEYNvP (ORCPT + 99 others); Thu, 25 May 2023 09:51:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240966AbjEYNvO (ORCPT ); Thu, 25 May 2023 09:51:14 -0400 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30E03186 for ; Thu, 25 May 2023 06:51:10 -0700 (PDT) Date: Thu, 25 May 2023 13:50:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=5aoyqs344fhubkfvtkwrcry4xi.protonmail; t=1685022668; x=1685281868; bh=6YZpbdH442xI5ahkra+Rj8DusW4wlxrFG6pdXqv769o=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=cic8tsuMcaYjh0AMhivCkzsA+0kzurdnfjqVM765he8bkT8tkQgrvp089nwYJM+CV d+5g0t8hYTSg+UVnh9GdmI8mJLILcuAojija4H84jbglWtt0EBe2Vn9aJKC/O+ndFc enZU/AhuEDoBcJU1vjw3OcCmojJcjBzMj+SXv9FUe37Ha7+TUNuxFXiTj3g76iXmsX rLbrf1JqGnl8uRanlVDMT5auqTdYbAvMWVpo1jB5AL8AKyijOWa7Wca+tgus1dozq4 krlOwEsJagjMUrOKP6xRyLSc607E20mjjNLUrOSJXWGbY4wyx0NkWBlEbrQbv1Mbcn hz7mlX575i33w== To: Alice Ryhl From: Benno Lossin Cc: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Will Deacon , Peter Zijlstra , Mark Rutland , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Wedson Almeida Filho Subject: Re: [PATCH v1 2/2] rust: sync: implement `AsRef` for `Arc` Message-ID: In-Reply-To: <20230517200814.3157916-2-aliceryhl@google.com> References: <20230517200814.3157916-1-aliceryhl@google.com> <20230517200814.3157916-2-aliceryhl@google.com> Feedback-ID: 71780778:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/17/23 22:08, Alice Ryhl wrote: > This trait lets you use `Arc` in code that is generic over smart > pointer types. >=20 > The `AsRef` trait should be implemented on all smart pointers. The > standard library also implements it on the ordinary `Arc`. >=20 > Co-developed-by: Wedson Almeida Filho > Signed-off-by: Wedson Almeida Filho > Signed-off-by: Alice Ryhl Reviewed-by: Benno Lossin > --- > rust/kernel/sync/arc.rs | 6 ++++++ > 1 file changed, 6 insertions(+) >=20 > diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs > index 274febe3bb06..9ec911e4a0c7 100644 > --- a/rust/kernel/sync/arc.rs > +++ b/rust/kernel/sync/arc.rs > @@ -264,6 +264,12 @@ impl Deref for Arc { > } > } >=20 > +impl AsRef for Arc { > + fn as_ref(&self) -> &T { > + self.deref() > + } > +} > + > impl Clone for Arc { > fn clone(&self) -> Self { > // INVARIANT: C `refcount_inc` saturates the refcount, so it ca= nnot overflow to zero. > -- > 2.40.1.606.ga4b1b128d6-goog >=20 --=20 Cheers, Benno