Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1317889lqa; Mon, 29 Apr 2024 05:25:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWsjNDTJlpces2KJI+WP+YwoqO2PMtUImrE9CntuPb8WTqx9kwYmK6xlwD8KEmWiF/73TRXctFw+xTRoiLbwmi1ja/Im4n7X85uAxjyqQ== X-Google-Smtp-Source: AGHT+IF+lSiHLghgkBiVJiEigioG5qltz5UlVpFiSpVyJcfNP4dQBahrebHD41sk3jPSw2iBdT2C X-Received: by 2002:a05:6512:20c8:b0:51c:17d5:b56e with SMTP id u8-20020a05651220c800b0051c17d5b56emr4592901lfr.11.1714393523286; Mon, 29 Apr 2024 05:25:23 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i4-20020a17090639c400b00a5222f3db32si14581361eje.687.2024.04.29.05.25.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 05:25:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162246-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@garyguo.net header.s=selector1 header.b=bFFAk7gJ; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-162246-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162246-linux.lists.archive=gmail.com@vger.kernel.org" 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 am.mirrors.kernel.org (Postfix) with ESMTPS id CFAB91F240EA for ; Mon, 29 Apr 2024 12:25:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D56655474B; Mon, 29 Apr 2024 12:24:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=garyguo.net header.i=@garyguo.net header.b="bFFAk7gJ" Received: from LO2P265CU024.outbound.protection.outlook.com (mail-uksouthazon11020002.outbound.protection.outlook.com [52.101.196.2]) (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 5593754743; Mon, 29 Apr 2024 12:24:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.196.2 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714393464; cv=fail; b=sl5cKxG72d5BqAKn/i3zgMosayKnYuLm3zDvzzPZJAo78i+l9/sEs0GpYHHg6pDGFMLUanwL5Y7b/7gbIOqVL+O8qwuQrF+e4dZO+ZmznyibrhBgnafq59x3Q0zATdL3nisFRTugiyy0jYBGskFED8sEdSe15hrJyL0mng9xpFc= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714393464; c=relaxed/simple; bh=b5bjTb/A32yUhU8OdsQsM4ffPfJ1WF0MJd8vQV8VT6s=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=U915E2VgPbN3pri8VpQrVX5RYV8IaoXleIqk/lEAOMkiVbBzxF3b0ppBxgQiNcigR07Ak1HLY20N1NJ3cfg+unrHZzh8KOh+VuM8G3ifNwLABjzytFEyrBMoQk4AEXI5/4E4j8ENysYjQ3j7zXcHe+4+P96Y98UApsWf0yZlgJU= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=garyguo.net; spf=pass smtp.mailfrom=garyguo.net; dkim=pass (1024-bit key) header.d=garyguo.net header.i=@garyguo.net header.b=bFFAk7gJ; arc=fail smtp.client-ip=52.101.196.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=garyguo.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=garyguo.net ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c+aNnhPC/LhEPM6zz+R7vWIgpnT63QPjFOVgU48GWpYAbk4tAmRmeStePXjHnFYt8p5PGlP0dMmC+svSyA8KnI14USDm0iIzcTMgqomRTUmPkEC7yRrwuk+bNBFbq9DM29rl7DhQH1MpNlXphZSIkmxA6augqOsISIUYb+1tSjYMcOpNQBDPXMhimghpB+ZK39mPl2Khpic0OymnKVazZrK1pU5yFxMwTKP38g0JKBPFqLeDt7XXG80FAYP+gYOmPCYUff7gIoxSZVyd/iXCutp/ZgHvKJXaYBWUPacuRBsX/SRm0z0m+9lP5qRmQMyi3Foe6TFgIkCyPqHkmsRdCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6jMQyN0LbbbZz064ZdtXIzr0cLADfmjVzx7B5fQ2HCo=; b=Wx7wTzqfvK3VB1/zjt1iX2PsyM56pXzyVLCmkUBfhan6qGW9DpA4gHMRJpEkrAgKBRf3XmyxjwceDfA7lICXbWtq0hr5okgjpSz2/X6lyOnL6JUYCs6LnppcrR98HmLMTJ6XYy1+LsglGuQA4+XS5Wakjg/KbZgL79ojknUBvY6QJVHQJl6VtgiT7NcK1x4DRAwD/sjoMV6Uqy2Fm70NNOj6OzXroPzXOINKvwoPXTq67IkaIV8sm3Dr20Z34IPIyzbsGlebVZkb6FYNEPTGusKBDE0Ew5fy/8dx+YDUkcRIPtxpVmKePc0ziLsbZPk8LE9FSbnAaG1X5LuYlOFVSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=garyguo.net; dmarc=pass action=none header.from=garyguo.net; dkim=pass header.d=garyguo.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=garyguo.net; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6jMQyN0LbbbZz064ZdtXIzr0cLADfmjVzx7B5fQ2HCo=; b=bFFAk7gJVCl7A/NI3zr6CRnEsZZ4+sXQYHPkBaW3TWjm9Ad81TCqc10CiAs/QfopzlFKV8NEd8x2ETRBAXftwvfhIL6uvBNEl5cZzVTuAhtmZiTV9oTJkZ63nXUZkz8SiAjBgapQSBArNblHzDYUnUmvuPcLb3DV3TYcExJ57A8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=garyguo.net; Received: from LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:253::10) by LO2P265MB3070.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:179::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.35; Mon, 29 Apr 2024 12:24:19 +0000 Received: from LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM ([fe80::1818:a2bf:38a7:a1e7]) by LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM ([fe80::1818:a2bf:38a7:a1e7%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 12:24:19 +0000 Date: Mon, 29 Apr 2024 13:24:15 +0100 From: Gary Guo To: Benno Lossin Cc: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , =?UTF-8?B?QmrDtnJu?= 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: <20240429132415.3039940d@eugeo> In-Reply-To: <20240425213419.3904105-2-benno.lossin@proton.me> References: <20240425213419.3904105-1-benno.lossin@proton.me> <20240425213419.3904105-2-benno.lossin@proton.me> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P123CA0256.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:194::9) To LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:253::10) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LO2P265MB5183:EE_|LO2P265MB3070:EE_ X-MS-Office365-Filtering-Correlation-Id: 852f5cfc-edfb-4960-0ea4-08dc68474ad7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|7416005|376005|366007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?tHg8AIjITtHll5JBKdkDoj0agXzuxqjb3+h6HOUrjc16jb37pQzGdL/DYe0m?= =?us-ascii?Q?cAgeH6b5+bgyJr6aazelv5d8Poz4MgCoPfpr1d28sYfBYVOYwGN5cGzt0ujt?= =?us-ascii?Q?JzamOLpMtTkM6Ya6Y5eTbqwNmR2e1N3GpyU7j1citKz5dcO2KZj5ztPXx+wK?= =?us-ascii?Q?dCrUr52D0tz8peGUyNW7Fmg8UpPVe0P6qXevGOnFG0B5Nzy7SpoSXpaYMZQ5?= =?us-ascii?Q?MDNaU385kOriafpRXf5/+PEeM3S9XOZru7WuGnUCOQ6rhhXKBxGOlYHSqVdf?= =?us-ascii?Q?QEKVJsBKaFAPvc7JwGXCs2SG6DWtbcOZk76n/hptA7Mi7Aco449EfRqJp+8p?= =?us-ascii?Q?icSR0nELtUEdmDUNLOle6KNqkDHsSjwzU/4i5Y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EiPLyVP5IH6PfRUeknmli3EeA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(7416005)(376005)(366007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?MN7cL+YSGjEMi2mMRIdoblRdOGabtiT/sffQM7w2BfDAwkCjTWOQPAv0F4at?= =?us-ascii?Q?CHpklDmNhlrGQSZhvFc1qzkXW3772DiEHxqGFGaaKtXvjFH9s061yiZf4TcJ?= =?us-ascii?Q?8B55GjV4IjNAzMm4u7wwW1LB3oV5sy23obo1MWBwu2vPbNSRm99ms573VmL0?= =?us-ascii?Q?0cyXJ+cVuxKeq/whrysrFIY2zyvl89lNhYtvpXn7auC2pqi6cNNoiKze9S4/?= =?us-ascii?Q?9EZNJgW2Qy4lt/3USVPgbYllCA19cKXXZSsL50toDYyBL3HSduOTZ2oku6gz?= =?us-ascii?Q?BYAYmbivkVQKbBgRcVUfgHCD/479KNBEQKg1ZOd7aM068y7Q6HV6iHuqiDFR?= =?us-ascii?Q?bVq9kr3ahbtvURHzuA6urtv0DPJwDZ1GuIyL3M2kEDOY5W9Z3mwPHjWHHVQO?= =?us-ascii?Q?/8uMh08Wdi098E9A2voFLw85LT75E3CCQR44OUBMhoBYGGVvGUWS90snmlwu?= =?us-ascii?Q?9idk2xqzPhqifpt3wQP/QlgtM6qU4x80w1WkaC8y16omEMJ8IjrRpr+kcXki?= =?us-ascii?Q?ycfWxKqNhr0Qq9VvohTsB2x1YfMR4AWZ6Yofd/8N2f1v0DjOHZGbtpM2OO19?= =?us-ascii?Q?TFZSsXPBP6v22I6o+vS7PsC4i8DHKEjW2ThC3Rnvz0ukGRS+VRok3nCiGVtk?= =?us-ascii?Q?HBKPQIO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xIQwD0IsD?= =?us-ascii?Q?/02t+VSyITvEwilnEPx0rejY0hVfDRTFxm0BxAnY?= X-OriginatorOrg: garyguo.net X-MS-Exchange-CrossTenant-Network-Message-Id: 852f5cfc-edfb-4960-0ea4-08dc68474ad7 X-MS-Exchange-CrossTenant-AuthSource: LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 12:24:18.9424 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bbc898ad-b10f-4e10-8552-d9377b823d45 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JJP4OYn2t9YqTmjU4YmNLoi4IoDplOil7EOa+inm/7YjHg/cvomqDHGezS5mIf5ib211MnrBJdIkD25gV62Ivg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO2P265MB3070 On Thu, 25 Apr 2024 21:34:44 +0000 Benno Lossin wrote: > 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-57ad3f5bc592@proton.me/ [1] 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. 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`? Best, Gary