From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07618C7EE24 for ; Mon, 8 May 2023 20:29:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232161AbjEHU3L (ORCPT ); Mon, 8 May 2023 16:29:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbjEHU3I (ORCPT ); Mon, 8 May 2023 16:29:08 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9B3149C3; Mon, 8 May 2023 13:29:05 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 5C8025C0121; Mon, 8 May 2023 16:29:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 08 May 2023 16:29:04 -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=fm3; t= 1683577744; x=1683664144; bh=G+jMg55hOCbbocEq58MWNDAQoerhosGi6pJ guyIM6MA=; b=UUMbwrGeXkFMipqOEKf0dX+bYnqTaHbps0bjOM5+1ODVYLW5Sxv Ig+gcOoNtgT9js4RcUG4lY3bnS+O4v2cQXUP3PLuGETZWYDfood/lfgvht+Ld0I2 /gt4D7eJFLQEeVMdm1rTAjzZajhnkqkMmvbZ4kiQGtgdHdqpmRSJrcpdDXhna+lk t3ijAC2QcJzFvJLG7PI3Tr/5qmye3CY3n/7uKcXpqOxtY4zBGbep2Fjk8bug9cRo +FTWjLcr8ebvts1IJMJI3j1OefQ5uqUj94iy0rLljhIxukZvnla1FvZiOat6xuom LsRD7iYmTcZXFr4XCp/JXmrsWiJdWfLQa+A== 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=fm3; t= 1683577744; x=1683664144; bh=G+jMg55hOCbbocEq58MWNDAQoerhosGi6pJ guyIM6MA=; b=T39FrWc6UnUy+llTJ+G4RR7R1tsi13odoejvkqf1fTWTgFcwIwm /W/7dl789lCqMOe3fc+jOeeSJ2GKlLH7Sp6BCM7TJbRtuXa5m6wLo1iYjrHxP81K 1NYjvE8jq585Oq6M/lc+kbWOOiHt8LUbg86K8G5U5NV2HzoTCMB0ay29JpWh/h/E ui0vFOhuNtqzTlNltrjA+pxIMH8ugwwtx0Ji5Y9vYV4IqSORlkmyeKJk+6aCLo6y EYI13qNgkwRF1gTfA+VeQxbndH4u5xV9qZpM0KidNvV2QGb1ZKqe2U8Ay7+plXig 04TIiJo9hyY3sP/NkcoBFPRzzPEhXVQAFZw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefkedgudeglecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfevfhfhjggtgfesthejredttdefjeenucfhrhhomheptehl ihgtvgcutfihhhhluceorghlihgtvgesrhihhhhlrdhioheqnecuggftrfgrthhtvghrnh epheduuddvteekvdektdduledugfffhfdugeejgeeuvdevtdetveejheehiefffeegnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlihgtvg esrhihhhhlrdhioh X-ME-Proxy: Feedback-ID: i56684263:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 8 May 2023 16:29:01 -0400 (EDT) Message-ID: Date: Mon, 8 May 2023 22:29:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH v2] rust: str: add conversion from `CStr` to `CString` To: Gary Guo Cc: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor , Boqun Feng , =?UTF-8?Q?Bj=c3=b6rn_Roy_Baron?= , Benno Lossin , Martin Rodriguez Reboredo , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev References: <20230503141016.683634-1-aliceryhl@google.com> <20230508124127.77a97c54.gary@garyguo.net> Content-Language: en-US-large From: Alice Ryhl In-Reply-To: <20230508124127.77a97c54.gary@garyguo.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/8/23 13:41, Gary Guo wrote: > On Wed, 3 May 2023 14:10:16 +0000 > Alice Ryhl wrote: > >> These methods can be used to copy the data in a temporary c string into >> a separate allocation, so that it can be accessed later even if the >> original is deallocated. >> >> The API in this change mirrors the standard library API for the `&str` >> and `String` types. The `ToOwned` trait is not implemented because it >> assumes that allocations are infallible. > > How about add a `TryToOwned` trait to the kernel crate and implement > that trait for `CStr` instead? Eh, I don't think it's worth it. It doesn't give anything new to the CStr api, and I think it's rather unlikely that someone will actually need to be generic over such a trait any time soon.