Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4237894rwd; Tue, 23 May 2023 05:19:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5blo/21ggHdyiaWXE8vH3m++ZSfW41sROWB7cC83sgFZsFCZ3PRMAEWpLBHyRclaYY1m/A X-Received: by 2002:a17:903:32c7:b0:1ac:43ea:7882 with SMTP id i7-20020a17090332c700b001ac43ea7882mr16651201plr.29.1684844355889; Tue, 23 May 2023 05:19:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684844355; cv=none; d=google.com; s=arc-20160816; b=QO2fh3gNXSywVR17/vBa1uQUs9gQq0Xl85ah1fQAYiDYmprYQ3Xo7AxSlhWIVii0EY JmL2njtf0++x/5JgjsXlnJbUH9O2yUuWn+6G8LTxsSBVcXGlQ4nLJ+YOw5rkMDnhPMzS sQX0ej3s9v6MwoRjqqy+8Dk3HcCS7i+W5vvbYgVHaVvsiMeb3N8+2iHLzDK9ShaTeV1y 6C/+0zsoYcwF+M2XkthvqmTpa7SR+smL1mQN1yr03ls97u/oZTFg1citaQdVcDVQN/tR rBFxrPz9sz7iWJI0KZzJPPzmjL80Gsi9WVOBaKVyNB9lLG8PdXfT2AfCUlZBp0Pvxxyj aQRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:in-reply-to:date:subject :cc:to:from:user-agent:references:dkim-signature; bh=QR1MUsbPkF8iaQNWtY/LtUVVkhUDmli1/tIye2VFdbE=; b=UIEA2rYrRusWxrSl/8bHlAYekWr2Bow6MH/HsEnP1m2cacIiuFAxOXDrOaX+YH1hn9 ogOrLBaVY51O1MejyPieGpPudw/KXeyOqd5pdbJr/Zud0Dx2/8sb8ZvqOOFQvbPMCTRn nfAxILwB19Tx/dClZlyQz/57M/8fSD0/T/Bgk2QY7fMkaCN85IDzaMAIo3IYHA/vgRXn LKhwT5uU8YolGFtwH/l9w6D+dzC/b8Ktst3HsnhzumVRdFKSroeMpitxL1dq9QQOVtnE oIFwDBEaRW3SJg3+mZy0mLetixC1BdYd3jL4jyjQKW6v3eGtZKtUw5Tc/+NuwzcR9rL/ QNcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@metaspace-dk.20221208.gappssmtp.com header.s=20221208 header.b=qvuLsz9F; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ix5-20020a170902f80500b001ae1bb70a41si2008176plb.168.2023.05.23.05.18.56; Tue, 23 May 2023 05:19:15 -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=@metaspace-dk.20221208.gappssmtp.com header.s=20221208 header.b=qvuLsz9F; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236618AbjEWL7d (ORCPT + 99 others); Tue, 23 May 2023 07:59:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233227AbjEWL7c (ORCPT ); Tue, 23 May 2023 07:59:32 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 304DD118 for ; Tue, 23 May 2023 04:59:26 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-96f7bf3cf9eso860770466b.0 for ; Tue, 23 May 2023 04:59:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=metaspace-dk.20221208.gappssmtp.com; s=20221208; t=1684843164; x=1687435164; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:from:to:cc:subject:date:message-id:reply-to; bh=QR1MUsbPkF8iaQNWtY/LtUVVkhUDmli1/tIye2VFdbE=; b=qvuLsz9FjN+Ow6wPHmpPN9sq2xFW9UaiuZI8/RpzQTI46zGMjP+7RZAHi5FzfnzJSS hMlsWys/2phDu/pqehttwGb9aySSa8jbSxaTcbAPy7Mp1e5GuDioXy939L7T+V94S2ZA WIqthatCBC4qzoA5rPWm2W5kSwpTqIzNnC4IxUnuv5tz5nNEmE4T+Xsbu7quBpCUWkUP BOmC1G57K4/Jon8MuFyGFjeubHVzPCgyXDykRd00TrdEUnDvWXY5Zyy6A33txfd8Zfye u206w72qGadaHLfEI64LE8stqTZ4PIiN+HpE1ShYEM2Wd2uGI0aTyxStrXta5mlf1Ckc 1isA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684843164; x=1687435164; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=QR1MUsbPkF8iaQNWtY/LtUVVkhUDmli1/tIye2VFdbE=; b=TEJs1oi/AEcwOOVkRkvoixAF6KOFORFnMvM4HVan4VqiryrzlGgy5/h+8guK8dH8b3 Bi99vAvp8IDP2iuZ4eH/qVRhRUkP/yT93RnBJBNEbMLxPUH4m2WvEYZgk+vG22XkdTV3 MOPGOQP26TOrk/Z3pzDnQeTRmpzScukLdbrkU5WDUXAZagGppU8V9dTfkVrO3+S9Dx3e UMitfkH3DKfwAWcftGyOIo+xCEpJsoSGji6hXISIx+4hyA8Cfv9EDJ7at2KvHWVMEc+K Iy4aBOLp8j/u9vNvEVcAfk+Z92AYprARj9iqu3J0MtkNnsbAIliVJ4ZPmNP00oP4NSID esYQ== X-Gm-Message-State: AC+VfDz25oyXL1T860bSyqCqQTpeu4fmM+Z+WmmwEFfO+ondzET9nwhI 0q+sWHFDMiqSvP5F9E89ZUCb7w== X-Received: by 2002:a17:907:8a12:b0:93e:fa12:aa1a with SMTP id sc18-20020a1709078a1200b0093efa12aa1amr14084404ejc.1.1684843164632; Tue, 23 May 2023 04:59:24 -0700 (PDT) Received: from localhost ([79.142.230.34]) by smtp.gmail.com with ESMTPSA id cf11-20020a170906b2cb00b0094ee700d8e4sm4321311ejb.44.2023.05.23.04.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 04:59:24 -0700 (PDT) References: <20230517200814.3157916-1-aliceryhl@google.com> <20230517200814.3157916-2-aliceryhl@google.com> User-agent: mu4e 1.10.3; emacs 28.2.50 From: Andreas Hindborg To: Alice Ryhl Cc: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn?= Roy Baron , Benno Lossin , 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` Date: Tue, 23 May 2023 13:59:00 +0200 In-reply-to: <20230517200814.3157916-2-aliceryhl@google.com> Message-ID: <877cszfeck.fsf@metaspace.dk> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 Alice Ryhl writes: > This trait lets you use `Arc` in code that is generic over smart > pointer types. > > The `AsRef` trait should be implemented on all smart pointers. The > standard library also implements it on the ordinary `Arc`. > > Co-developed-by: Wedson Almeida Filho > Signed-off-by: Wedson Almeida Filho > Signed-off-by: Alice Ryhl Reviewed-by: Andreas Hindborg > --- > rust/kernel/sync/arc.rs | 6 ++++++ > 1 file changed, 6 insertions(+) > > 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 { > } > } > > +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 cannot overflow to zero.