Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2237825rwl; Thu, 30 Mar 2023 07:47:40 -0700 (PDT) X-Google-Smtp-Source: AKy350Zm/F3hVSEr10eXgg+DOvTCqN/S1yPFlII4W60CjB2qbN0eAKbjDYT/QFtcuHB26VfJ5PCm X-Received: by 2002:a05:6a20:7da6:b0:d9:d1e6:82ac with SMTP id v38-20020a056a207da600b000d9d1e682acmr2323904pzj.5.1680187660186; Thu, 30 Mar 2023 07:47:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680187660; cv=none; d=google.com; s=arc-20160816; b=MiUFM2OUO9QRVGiM4jl+UP0SRV2kii4om7zbVpusdGSzIDbc6xQeTWB38S2FphFZ5h iGSWCNKoqCcusCcJmoajmAuBVo72/GJ6xuch8KUG9ZPwJCEKt9c13sXOj/GcoZo5IE6g tTA6ZFg0ZHMz/MQeBXhnYZNedRUZCNNOpUAlpCk2mSWBeN/sQj6tfe3i9skWS5ClcRHs 9UM+rd+VY+tocWYYqDpoKN3xf/fD8LTLZUkuwVORL6CEMdbr3IYQVW6BmTcCLcneDTZ2 uJkgO405BCAxgZr1RYRIW49Ehqzp8vgkbmXb6Mu2XJe1e/F/fcIgP72V5hiLO3gLNWB7 UBEw== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:feedback-id:dkim-signature:dkim-signature; bh=mEU0nion2muXlTfUR8cesDV/AWMQCwWe/7kpJqZM+CM=; b=qLghf/ZeO2mre6WZyrBm0vqiq+unDLCVs0nkB5AN4bExa6QIJqw/KCm3q2xfbcD0hG pNloOZgAGwOa0JYvKiAw6cRcJdv0KDZN8zRh8WYiDm9spOgBiZr4socFxZC49xF/1fns fQCSH6I3YoDbH2cRAwu01H+4618iB6NPipzIA0qk7Lwrwl+jBhkYHPEZfqs6EFVHNL0s xDrGWmxnlDWRaxKOh+8Fr7EfYPIddqYXXoqjDUU9B1YGP1bgPQm+ZhLdYHy+e+0NvY9q QvyzqPOV5XlF3XL/UnQLmIXSypCKCF/hIkdf1eWerrsh1bbHeGlAdFzE87cz0MFUdz5U kguQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ryhl.io header.s=fm2 header.b=lOcePaeE; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=U+1Ihw8g; 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 a3-20020a056a000c8300b00619b451da30si118245pfv.209.2023.03.30.07.47.27; Thu, 30 Mar 2023 07:47:40 -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=@ryhl.io header.s=fm2 header.b=lOcePaeE; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=U+1Ihw8g; 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 S231936AbjC3Og5 (ORCPT + 99 others); Thu, 30 Mar 2023 10:36:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231396AbjC3Ogy (ORCPT ); Thu, 30 Mar 2023 10:36:54 -0400 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE3AC5BA0; Thu, 30 Mar 2023 07:36:53 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 5C848320092D; Thu, 30 Mar 2023 10:36:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 30 Mar 2023 10:36:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ryhl.io; h=cc:cc :content-transfer-encoding:content-type: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= 1680187011; x=1680273411; bh=mEU0nion2muXlTfUR8cesDV/AWMQCwWe/7k pJqZM+CM=; b=lOcePaeEvFUwkff08Ll9SURQYawK4c3C361GvZCwPNO8rSTU1vg srgt5wYHN1Yy40ktgnBGN0nd3E3TsYANDXNm9/Ozsp55ZAoFXN4VZ3Z2QkbhL6jN hdWhhPsgTK/DBP8IEvRTtPD1VsIKmszGKwp21ztfYvT4sWTWLUyIJ8CjdynUooII g7KufWKRbsCK4z+CVq0dUPvraGm8nGf5vU8R2FpDFI+RYwEiFzkQ+9HT/bBNFdCU AxeH8n1EkukN7daXHS4H8FpOOVPKr+08KlXq28/ENZIMDzWQlkqaOZblQ9qD3U39 oJNz4/eioT5pmdrZdgYlKcvdrcHjObCryqA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type: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= 1680187011; x=1680273411; bh=mEU0nion2muXlTfUR8cesDV/AWMQCwWe/7k pJqZM+CM=; b=U+1Ihw8g8cVw3w0tdthGsHQW7Sg73ShV9oapDg+bYlxpaITQJpF fOzcy6YWltiSJp9TFqtLRiS1R/PA20uF8f2t/j9oadz1isaD6OvLQ78TdlWRdYk9 KrCAfDgJlou6E8VcCM/VNnLpfqal0YXiD1WyH6E/C2mLRc5dTpzsyDl9WCn9B5jk /kMZKcQjkM82Eb5yfrKFMZexfgV3jBChJXpnS7YC/P7asXQV2p5edjEZHOISA+eo AdYqnlQiRiERUpgPa7eubr1Pb/Wgdw7nkFgl8QKsIECfbQARGi5yW6JgrXd2dU1+ Fa2accxo1rTadDmsrOUb2mUXjxJ0HO2akdw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdehkedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpeetlhhi tggvucfthihhlhcuoegrlhhitggvsehrhihhlhdrihhoqeenucggtffrrghtthgvrhhnpe ehudduvdetkedvkedtudeludfgfffhudegjeeguedvvedtteevjeehheeiffefgeenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhitggvse hrhihhlhdrihho X-ME-Proxy: Feedback-ID: i56684263:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 30 Mar 2023 10:36:49 -0400 (EDT) Message-ID: <1f93a045-5bd8-e07f-cf1b-7b1196c8ab54@ryhl.io> Date: Thu, 30 Mar 2023 16:37:01 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH v3 06/13] rust: init/sync: add `InPlaceInit` trait to pin-initialize smart pointers Content-Language: en-US To: y86-dev@protonmail.com Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=c3=b6rn_Roy_Baron?= References: <20230329223239.138757-1-y86-dev@protonmail.com> <20230329223239.138757-7-y86-dev@protonmail.com> From: Alice Ryhl In-Reply-To: <20230329223239.138757-7-y86-dev@protonmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 3/30/23 00:33, y86-dev@protonmail.com wrote: > From: Benno Lossin > > The `InPlaceInit` trait that provides two functions, for initializing > using `PinInit` and `Init`. It is implemented by `Arc`, > `UniqueArc` and `Box`. > > Signed-off-by: Benno Lossin > --- > > +/// Smart pointer that can initialize memory in-place. > +pub trait InPlaceInit: Sized { > + /// Use the given initializer to in-place initialize a `T`. > + /// > + /// If `T: !Unpin` it will not be able to move afterwards. > + fn pin_init(init: impl PinInit) -> error::Result> > + where > + Error: From; > + > + /// Use the given initializer to in-place initialize a `T`. > + fn init(init: impl Init) -> error::Result > + where > + Error: From; > +} This definition is potentially rather limiting, because it can only be used with error types that can be converted into a `kernel::Error`. What do you think of this alternative? pub trait InPlaceInit: Sized { fn pin_init(init: impl PinInit) -> Result, E> where E: From; fn init(init: impl Init) -> Result where E: From; }