Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6628550rwb; Mon, 5 Dec 2022 15:26:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf4lT1QNuJkmaK8NTScaSfM9nqSt7haFN4h+iJto7iphOvox2DxLVqQ9EpVYk+TWtagBw4Cs X-Received: by 2002:a17:906:3ad8:b0:7a8:dddc:7ec6 with SMTP id z24-20020a1709063ad800b007a8dddc7ec6mr21559293ejd.734.1670282781598; Mon, 05 Dec 2022 15:26:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670282781; cv=none; d=google.com; s=arc-20160816; b=bi6tJC5h5nKB98GNW8Z+apLNDekimXC31s1QMGDh3McSI1gEAwVFM8nxDjqvqIY7Sl NfQ5ld0pS9RorwFeTuGeDMM0LJWSIgoUmYPcW2g/7b8iEqH+Ir6wuXZMZ7IwMzzQp9qc isnUoCACYJPUC2NhNyKDPhXp6Jqf3CLz2aJ4ROg4RtIUOYnVysMnBO7c6s4L7qc4YNKk +k444XFi8rLNljYzugyn5QSEcCuHP2jvBHMI8Fw4piv7LasQZ/lc4nf6tDrwfqVD2vga ieQoaqaoBJYBRiorYmtLYP3BGkKyJXIQY816C2V5lw/Oejqgppkx3C2OKqDJHmst02uM AGug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=w+IeYZdl/jBckc+B8Ef5+2fkoYurFniYzp8I2WfjJAg=; b=QF8xtqV/cwHJnqqmifoEXU2uVfHhLg0vx04xcd1Nko7gzNFBxyFGvs14JqDt2b5OQy re8YhtYUsaqpALycqd5CqPM6l9MqvpeopPxbJNZ2s1RdhIgagmJuQV4aBEzPtkZn/dgb PSQysrFOYa//GUXsDUbj6HXtft18syEFeNamL+KRs7Uuokn/0SHVVPE0utCYcqX2s4pO fw1YIF5ft5+Nxu8IuKCmEp1mccEDhWlQu+mVx8SArM1xjIPRmJqjdKOvVdkjFSdzzKA0 zwXcvqQnZfhIjBXBcWZD3ojF9VdAcZJ9z1jDbiPc6pTKzJ1zW1QMdA0y8X6uO73xUZE4 HxXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joshtriplett.org header.s=fm3 header.b=v73bsI1Z; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=E5jxSz6M; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ec26-20020a0564020d5a00b0046125ddf5easi605794edb.185.2022.12.05.15.26.02; Mon, 05 Dec 2022 15:26:21 -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=@joshtriplett.org header.s=fm3 header.b=v73bsI1Z; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=E5jxSz6M; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233693AbiLEXAO (ORCPT + 79 others); Mon, 5 Dec 2022 18:00:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233602AbiLEXAM (ORCPT ); Mon, 5 Dec 2022 18:00:12 -0500 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4A441DF03; Mon, 5 Dec 2022 15:00:09 -0800 (PST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 950E85C0284; Mon, 5 Dec 2022 18:00:07 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 05 Dec 2022 18:00:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= joshtriplett.org; h=cc:cc: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=1670281207; x= 1670367607; bh=w+IeYZdl/jBckc+B8Ef5+2fkoYurFniYzp8I2WfjJAg=; b=v 73bsI1Zzl+PrRrnFAe74z/P5X5Ye8j8fquNTyUc1qVnyF7vUs4SaArQhkKa6/u40 gl3I2Oe2ZjAXjRPYigkM/gAutmcG/OkgrSq0BbQDxL0TF5ud1noUKQGJ2/UQrAUN G7/4aH3MHiGIYZ1XicYxUE1FKLGMX0F731YzNqw+2SgvQo8OftwhnPN6uGEw58QQ kKuXdsuCnziT1QqDvfyS9YCvHWTcmJgcVzANF4hwzSxvJn3dkKXDUhVsH37V1ZxM R0kZYKZCWuUVSp6XZ6cpgqr85LDVo4oAh9gR2C5TWr2THP0MktzjX2eB+9OzdOQD Ad+6Ix8I7wAzUum7qf6kA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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= fm1; t=1670281207; x=1670367607; bh=w+IeYZdl/jBckc+B8Ef5+2fkoYur FniYzp8I2WfjJAg=; b=E5jxSz6Mp7sHvXcwPtIZK90qQ/rR9TrWy5GoZL9q2tWn 7M4PgrompkamBn8jUN0SEkyzp6cMUG7Q/qtEkO/O8O2ZsIiaPiocQXb/3fBYWKa/ cdHMOAPgLFoUJ/Q2aHNnxSYGiXLqdGn2xHd18oMnVDR7OFtoqrkUsk32RAehRh+6 kcM8Gzkxwe8Cax6J5MfF+8LH3vWz5Om6dsMjVl2RtnBjNhCB2blH78wBuIbo0Dd8 vhH1LbPi1AkaTLAurbqaEXwJMFxgA5JAIMCpzfzysnwJgPV47o2ytUJ7ZatEXm4C S3fHTC7TJHVHB6w9OZQSHNTsC81UPptci5aqY14u5A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudehgddtgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeflohhshhcu vfhrihhplhgvthhtuceojhhoshhhsehjohhshhhtrhhiphhlvghtthdrohhrgheqnecugg ftrfgrthhtvghrnhepudeigeehieejuedvtedufeevtdejfeegueefgffhkefgleefteet ledvtdfftefgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepjhhoshhhsehjohhshhhtrhhiphhlvghtthdrohhrgh X-ME-Proxy: Feedback-ID: i83e94755:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Dec 2022 18:00:06 -0500 (EST) Date: Mon, 5 Dec 2022 15:00:05 -0800 From: Josh Triplett To: Wedson Almeida Filho Cc: Gary Guo , ojeda@kernel.org, Alex Gaynor , Boqun Feng , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Wei Liu Subject: Re: [PATCH v2 27/28] rust: types: add `Either` type Message-ID: References: <20221202161502.385525-1-ojeda@kernel.org> <20221202161502.385525-28-ojeda@kernel.org> <20221204103153.117675b1@GaryWorkstation> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 On Sun, Dec 04, 2022 at 05:36:08PM +0000, Wedson Almeida Filho wrote: > On Sun, 4 Dec 2022 at 10:31, Gary Guo wrote: > > > > On Fri, 2 Dec 2022 15:41:59 -0800 > > Josh Triplett wrote: > > > > > On Fri, Dec 02, 2022 at 05:14:58PM +0100, ojeda@kernel.org wrote: > > > > From: Wedson Almeida Filho > > > > > > > > Introduce the new `types` module of the `kernel` crate with > > > > `Either` as its first type. > > > > > > > > `Either` is a sum type that always holds either a value > > > > of type `L` (`Left` variant) or `R` (`Right` variant). > > > > > > > > For instance: > > > > > > > > struct Executor { > > > > queue: Either, > > > > } > > > > > > This specific example seems like it would be better served by the > > > existing `Cow` type. > > > > We use `no_global_oom_handling`, which gates most `ToOwned` > > implementations (e.g. `str` cannot implement `to_owned()` because it > > cannot guarantee allocation success). > > > > So the Rust `Cow` is pretty much useless in the kernel. > > It's also implemented in `std`, which the kernel doesn't include. > (Which is actually good for us, since we can't really use it.) > > Josh, how do you feel about adding a `TryToOwned` trait to > `core::borrow`? This would be similar to the precedent of `TryFrom` in > addition to `From` for the fallible case, and would be usable by the > kernel. I'd expect it to be in alloc rather than core (though I suppose it doesn't *fundamentally* depend on an allocator itself), but I'd be happy to see a fallible version proposed, yeah.