Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp4303247rwl; Wed, 28 Dec 2022 02:07:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXsPqXI1c6OqPqQpMyeCLFwCDoRHlnVQKO1vMpcxJ6e60gGmaTXbOUud/Rsfu7F06927X9An X-Received: by 2002:a17:907:d489:b0:7db:55c1:6534 with SMTP id vj9-20020a170907d48900b007db55c16534mr22164087ejc.5.1672222052923; Wed, 28 Dec 2022 02:07:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672222052; cv=none; d=google.com; s=arc-20160816; b=pkrytqiPaeZP7OMSFeYCYRLb0GkFmLtsFNeonKzZqHI5SlgI+eZtQLIXdAzqArr03Z LHcvZOYi787FFosppQf+Zb1w9LNwyBOIa5USfFQrUujyo91CwWHkNTGCx7eo09vQe1Id KWviJPLYOHTNap80OelFE/3HtReeItlSLKRx64YxGGqr1pxSwfNK5Vet6fKVz8u5vHig xfZ8wuc/0IyRTSBPbaXjNmrZZHdrAUHygoAsikA0NNiHS1JeJPxeibOr3z9lsFPMfa4x bruiS3S5AkQWgkgUR4Rb1BACraMiMV+8Y3akSvYaajfopwdbtF2J10zIdLrIEuIZ5fmQ 45Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:feedback-id:dkim-signature :dkim-signature; bh=scLhASwGkwPallCX/RDeVmQQLR5UFqve9DQE5NCPGd0=; b=I9S+92RXzl4ct0o422L0uQ6YSTvOfRTYZUQvEQcc1thmu6BfuVL4aKqYlkz0aBMlek shzKe/5ipjt6zRHPQEeQPf+7J1JZURW9VU13FgqzoewIaRYwKxEPbk18xkfI24Ev4Gy6 1ewrcHGfXr9+D6/rYZb8rVWYTcRVmWQLhwFb9EfUoOdJsTA9CzXD0Ms/X6e+Ahu2shb2 chECAJHgH5V5HyUnlrIcQrGkO6PkAIlO4MXTPOgj47K6qmc7OvVeEERyHsJtaA18U0TM Pgn6sZWlI8yRP0SKK8dzb3SZTIl3om05BHeX2VyPMLtuyxdVyWSfUpmRmQH8k8Zk7HSe b2Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ryhl.io header.s=fm2 header.b=YNPEj2kD; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=ipfNBC3H; 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=NONE sp=NONE dis=NONE) header.from=ryhl.io Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb5-20020a170907960500b007c0c0d7c4c8si13030059ejc.44.2022.12.28.02.07.16; Wed, 28 Dec 2022 02:07:32 -0800 (PST) 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=@ryhl.io header.s=fm2 header.b=YNPEj2kD; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=ipfNBC3H; 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=NONE sp=NONE dis=NONE) header.from=ryhl.io Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232702AbiL1KDI (ORCPT + 64 others); Wed, 28 Dec 2022 05:03:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232920AbiL1KCk (ORCPT ); Wed, 28 Dec 2022 05:02:40 -0500 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 276FA101CA; Wed, 28 Dec 2022 02:02:31 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 8380D5C00E0; Wed, 28 Dec 2022 05:02:30 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 28 Dec 2022 05:02:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ryhl.io; h=cc:cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1672221750; x= 1672308150; bh=scLhASwGkwPallCX/RDeVmQQLR5UFqve9DQE5NCPGd0=; b=Y NPEj2kDgPgTKMR9pv+BAwdbWzRk+3O+Feq/MYXQYcn7C/9+eVKi9t3EYKj+dIQAy HIsHBBr+sHWQ9R2IGjBtf1c/wTTSP2mJgQ/N+5c6+fjAtkJ00htoblc1bRkmCfEZ N82a8Nid/WKfTlLTfzCh5uxK7uV0EM41Lfiox34QKZO2je3q5v2wax/GQoA7Dokj b7dCUIAoNRfKwkycwZm2ZhFWsDDWHMNcxP27t9ZZ7WLA8MpKs9ybjlJCIir4EojK AFSQODaOIfqy4PCiFOpS1Rvdd9EicLGKh3siXU0gfTPPIvYVjyoduT0FoRQEHX/e P8yyTmupLSvKtB/LLXo+w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1672221750; x= 1672308150; bh=scLhASwGkwPallCX/RDeVmQQLR5UFqve9DQE5NCPGd0=; b=i pfNBC3HOmaDLg04a7YS25WxxFAT1+y4qMiP5GY0TXb9HT6YMUB5geREo6N4A/KEs IFoBx/+xvrQfF9pQqTw/32nDQNiWC4HPCUj6hyVVXDL3QakDrbh+zi/+7mMjiDpL dWmo5Mov9PPT7oE2oGZMBVXWE08rgSYNWDwC9ZKG7pP3B9VtWCYB59HIiMXe62jA E5lAzlBLc6d7gSW7LKbh0t8vP+meA/x4yH90SifjhLazr2Mf2epcnOFc+aw+wB1H apgt0heHyHwpfSG8gI1xp7gwAZkO5MLUkwgIB2jWR+L2/URlmN0LytW3bpp82DPz kz3k4wSA6YpWgu+1H7jnw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedriedvgdduudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfhuffvvehfjggtgfesthejredttdefjeenucfhrhhomheptehlihgt vgcutfihhhhluceorghlihgtvgesrhihhhhlrdhioheqnecuggftrfgrthhtvghrnhephf ehueeileevjeefkeetvdffveffudeuhffgtedvuefgiefgiedvjeegvdejleejnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlihgtvgesrh ihhhhlrdhioh X-ME-Proxy: Feedback-ID: i56684263:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Dec 2022 05:02:28 -0500 (EST) Message-ID: <1643d84c-cd6a-6142-f7e9-f943a0489276@ryhl.io> Date: Wed, 28 Dec 2022 11:04:04 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 From: Alice Ryhl Subject: Re: [PATCH 5/7] rust: sync: allow type of `self` to be `ArcBorrow` To: Wedson Almeida Filho Cc: rust-for-linux@vger.kernel.org, Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=c3=b6rn_Roy_Baron?= , linux-kernel@vger.kernel.org References: <20221228060346.352362-1-wedsonaf@gmail.com> <20221228060346.352362-5-wedsonaf@gmail.com> Content-Language: en-US In-Reply-To: <20221228060346.352362-5-wedsonaf@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS 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 Reviewed-by: Alice Ryhl On 12/28/22 07:03, Wedson Almeida Filho wrote: > This allows associated functions whose `self` argument has > `ArcBorrow` as their type. This, in turn, allows callers to use the > dot syntax to make calls. > > Signed-off-by: Wedson Almeida Filho > --- > rust/kernel/sync/arc.rs | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs > index f68bfc02c81a..84f31c85a513 100644 > --- a/rust/kernel/sync/arc.rs > +++ b/rust/kernel/sync/arc.rs > @@ -255,11 +255,34 @@ impl Drop for Arc { > /// // Assert that both `obj` and `cloned` point to the same underlying object. > /// assert!(core::ptr::eq(&*obj, &*cloned)); > /// ``` > +/// > +/// Using `ArcBorrow` as the type of `self`: > +/// > +/// ``` > +/// use crate::sync::{Arc, ArcBorrow}; > +/// > +/// struct Example { > +/// a: u32, > +/// b: u32, > +/// } > +/// > +/// impl Example { > +/// fn use_reference(self: ArcBorrow<'_, Self>) { > +/// // ... > +/// } > +/// } > +/// > +/// let obj = Arc::try_new(Example { a: 10, b: 20 })?; > +/// obj.as_arc_borrow().use_reference(); > +/// ``` > pub struct ArcBorrow<'a, T: ?Sized + 'a> { > inner: NonNull>, > _p: PhantomData<&'a ()>, > } > > +// This is to allow [`ArcBorrow`] (and variants) to be used as the type of `self`. > +impl core::ops::Receiver for ArcBorrow<'_, T> {} > + > impl Clone for ArcBorrow<'_, T> { > fn clone(&self) -> Self { > *self