Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1521767lqa; Mon, 29 Apr 2024 10:44:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWI8B0+1UjLMkLHdmm7+oyiZtQbt+LVywh1G0Z9AJ9E8a1+qawppcrztmj/g0ABmuyuac+w0jO/VhvPC+famuXhVytdHOSg2s4FPiHOKw== X-Google-Smtp-Source: AGHT+IHvVWXcQLvXOX5Hhh9lmFYs0TMA63dW2HRuSfB53eNeWZvkJX6/fdQ+5U09y0ziE4pbwv1W X-Received: by 2002:a05:6358:798b:b0:17c:d10:722c with SMTP id j11-20020a056358798b00b0017c0d10722cmr11961527rwg.1.1714412690536; Mon, 29 Apr 2024 10:44:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714412690; cv=pass; d=google.com; s=arc-20160816; b=Gs0VGlb2/t0G608Y0pY0a8TKr+PzAaVIS5g1IBwzq2K5y0pusN0KeqTUtAEGO5uTv1 1RIwPqpohyd3UkeEhibEcLH6fXrcnqqAko8XKoW5+1pPi9+7yUg0nuCLvZxeRkaqBtTp u83DEWYUd5kIHNyZ1fMx1aEvw1E7XNkQbKaEMdF/Wc7cqavoibZvAK8aBRfHrfH4iXrE UJ6TDPgu3YxwtIS4BAJ9F0pM0Zx6/+PM/HCG4ZVZdt6wgfrw2mSb0f2idHibj7lt/Kaj Y3E0ipVlQokUFylbJoxKUYc6LcH2ZCvoUrx61v6Hm3ZC0M/GOglTQwSM31UpHjrLbSQD 6BxQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:feedback-id:references :in-reply-to:message-id:subject:cc:from:to:date:dkim-signature; bh=OHfQy3ul0uJldKkAAD2jEbA5GG0EwQWPkz9F2GwnSwk=; fh=U20dT50JgNI+mcjjzDk9M+Y9Ax5mCwiNjg91brhb8rk=; b=bVrh0czwf6nHD/qSD4eUfDZuiKEJglKXhwTRNbS9j+IBZMwUHaLy80XjP1C2g3aIqa oaYrR+0ZvUB4meGFsdwe8+6RWHBaG9zkGGxkYIuyrsXLDC9yXVo+9haDJLKxzCoYfp/c MaBptSmC9tR9BiwF7L1H7rrkLjK+lN3oSpOEXTTISWhzr7N378ydzsBCukfrHsd0F8RX wTkvfQedJrF5O3do+ElJ4GqSlZOpCbgubItaAM4cTS4bTiw/m4x9lCzD/cISe0P7Ev0Z zsQiWR0TRrrF5sN1oz2YQMGfqElUrjIRF5HWI/eKMPyphNGPGURlqhOcuFIoznrgoB6/ f2Mg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=CpVuOMEf; arc=pass (i=1 spf=pass spfdomain=proton.me dkim=pass dkdomain=proton.me dmarc=pass fromdomain=proton.me); spf=pass (google.com: domain of linux-kernel+bounces-162772-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162772-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l14-20020a63f30e000000b005e27218564asi19503073pgh.157.2024.04.29.10.44.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 10:44:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162772-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=CpVuOMEf; arc=pass (i=1 spf=pass spfdomain=proton.me dkim=pass dkdomain=proton.me dmarc=pass fromdomain=proton.me); spf=pass (google.com: domain of linux-kernel+bounces-162772-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162772-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D7013B20F12 for ; Mon, 29 Apr 2024 17:44:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03E891272C4; Mon, 29 Apr 2024 17:44:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="CpVuOMEf" Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C5E0126F2C for ; Mon, 29 Apr 2024 17:44:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412668; cv=none; b=bFyhEmZgF2WBcLfNWmI7Y0fo4WN/znHoLaAC1P5q/xJdX35STgkWrxVUCwhSIMvyOt1nFqcC3FxlYQW4ODr0To2yc6emKn9374Wx45hRSLoY62L4MiMSkEqraJlPYfDKZcdwcq7rueKTbaLkXJ+DanEOyJZ78gR8g8yvUrwlhGw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412668; c=relaxed/simple; bh=OHfQy3ul0uJldKkAAD2jEbA5GG0EwQWPkz9F2GwnSwk=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UkhLkRhvq34GMccBMPBA5ueGCRLDpb0e9+qRJ3c4eb6jp+pu+ijOHZ/DSO30iIMoNjsHH8WlEAK0NYsil8sCgTRypGlsQPewk/LIrrzlGdmRdK21lRLil64i9IKhw8Fkoi5bMuACMrOqFh1rhNoP4JCSMMs2pgq5G0rZ07VUHtg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=CpVuOMEf; arc=none smtp.client-ip=185.70.43.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1714412658; x=1714671858; bh=OHfQy3ul0uJldKkAAD2jEbA5GG0EwQWPkz9F2GwnSwk=; 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=CpVuOMEfhiBareejLuxq0hLh7zbxrwQ/GykeqzJcLa9ebtFMNbCTm5s9VZmyzm9bJ tWzL14T21dzBgZ5z5/rNuWVj4TZEd9GzWJjGuX1u1Jhno3ElH0uila5jsDJh1mi3XH +r9pe5EwjbfhtdafPXMH9B1tS3/9CUv9ovw+F5o7N8xcUZGamFlIGYVNZEcJo5YK/h 1325U5sWLn0qkAdkbNqU0puyQX2AHmrsf9wtc9D0ZQ+cQP0BNBiM0xfup1ycCtD4as vVwJEEE1/pQkN0juSqP/GBmZAOu7oNnPVjPh7wYBbSdQurgUHL1X3blaAO2YzO9HeT K8eJBTDgtwFEw== Date: Mon, 29 Apr 2024 17:44:13 +0000 To: Gary Guo From: Benno Lossin Cc: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] rust: init: add re-initialization functions Message-ID: In-Reply-To: <20240429132415.3039940d@eugeo> References: <20240425213419.3904105-1-benno.lossin@proton.me> <20240425213419.3904105-2-benno.lossin@proton.me> <20240429132415.3039940d@eugeo> Feedback-ID: 71780778:user:proton X-Pm-Message-ID: e96a42a100e9fa8aa33d798ae6d460c115f85155 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 29.04.24 14:24, Gary Guo wrote: > On Thu, 25 Apr 2024 21:34:44 +0000 > Benno Lossin wrote: >=20 >> Sometimes it is necessary to split allocation and initialization into >> two steps. One such situation is when reusing existing allocations >> obtained via `Box::drop_contents`. See [1] for an example. >> In order to support this use case add `re_[pin_]init` functions to the >> pin-init API. These functions operate on already allocated smart >> pointers that contain `MaybeUninit`. >> >> Signed-off-by: Benno Lossin >> Link: https://lore.kernel.org/rust-for-linux/f026532f-8594-4f18-9aa5-57a= d3f5bc592@proton.me/ [1] >=20 >=20 > I don't find the re_init name very intuitive. From the name I would > imagine these functions be taking a `Box` and a `impl Init`, > dropping the content and produces a `Box` again. I see your point, but if you look at the link [1] from above, you will see that there such a function wouldn't be helpful. > Would it make more to rename the existing functions to have `new` in > their name to indiciate that they allocate, e.g. `pin_new`, and have > these functions that only does initialisation `init`/`pin_init`? Since we now have full control over `Box::new` (via `BoxExt`), we could also make it take a `impl Init` instead of just `T`. And we could also provide `fn pin(impl PinInit) -> Pin>`. I would happily rename the `re_init` functions to `init` in that case. But if we don't want to do the other rename, then I think it would be confusing to have the functions `new(T)`, `pin(T)`, `pin_new(impl PinInit)` and `new_in_place(impl Init)`... -- Cheers, Benno