[{"id":3683025,"web_url":"http://patchwork.ozlabs.org/comment/3683025/","msgid":"<DI4A9AFPGL3D.16M7U97LU7B4R@kernel.org>","list_archive_url":null,"date":"2026-04-27T22:16:20","subject":"Re: [PATCH 02/24] rust: types: add `ForLt` trait for higher-ranked\n lifetime support","submitter":{"id":89037,"url":"http://patchwork.ozlabs.org/api/people/89037/","name":"Danilo Krummrich","email":"dakr@kernel.org"},"content":"On Tue Apr 28, 2026 at 12:11 AM CEST, Danilo Krummrich wrote:\n> From: Gary Guo <gary@garyguo.net>\n>\n> There are a few cases, e.g. when dealing with data referencing each other,\n> one might want to write code that are generic over lifetimes. For example,\n> if you want take a function that takes `&'a Foo` and gives `Bar<'a>`, you\n> can write:\n>\n>     f: impl for<'a> FnOnce(&'a Foo) -> Bar<'a>,\n>\n> However, it becomes tricky when you want that function to not have a fixed\n> `Bar`, but have it be generic again. In this case, one needs something that\n> is generic over types that are themselves generic over lifetimes.\n>\n> `ForLt` provides such support. It provides a trait `ForLt` which describes\n> a type generic over lifetime. One may use `ForLt::Of<'a>` to get an\n> instance of a type for a specific lifetime.\n>\n> For the case of cross referencing, one would almost always want the\n> lifetime to be covariant. Therefore this is also made a requirement for the\n> `ForLt` trait, so functions with `ForLt` trait bound can assume covariance.\n>\n> A macro `ForLt!()` is provided to be able to obtain a type that implements\n> `ForLt`. For example, `ForLt!(for<'a> Bar<'a>)` would yield a type that\n> `<TheType as ForLt>::Of<'a>` is `Bar<'a>`. This also works with lifetime\n> elision, e.g. `ForLt!(Bar<'_>)` or for types without lifetime at all, e.g.\n> `ForLt!(u32)`.\n>\n> The API design draws inspiration from the higher-kinded-types [1] crate,\n> however different design decision has been taken (e.g. covariance\n> requirement) and the implementation is independent.\n>\n> License headers use \"Apache-2.0 OR MIT\" because I anticipate this to be\n> used in pin-init crate too which is licensed as such.\n>\n> Link: https://docs.rs/higher-kinded-types/ [1]\n>\n> Signed-off-by: Gary Guo <gary@garyguo.net>\n\nSigned-off-by: Danilo Krummrich <dakr@kernel.org>","headers":{"Return-Path":"\n <linux-pwm+bounces-8728-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pwm@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=gCSOdWN5;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=linux-pwm+bounces-8728-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"gCSOdWN5\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org\n [IPv6:2600:3c09:e001:a7::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4HzM2D3Dz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 08:19:11 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id AA2593027161\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 22:16:28 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 57E9F34DB6C;\n\tMon, 27 Apr 2026 22:16:28 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 333CA191;\n\tMon, 27 Apr 2026 22:16:27 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 3EAAFC19425;\n\tMon, 27 Apr 2026 22:16:22 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777328188; cv=none;\n b=VKIt/Cx2TXpK8/GgamSTk+bHeTrnRLwWtyjn0Mvh8k6SwIUYxD1TIUsCwZPbdWuGzdJ0h3Y0MFAgJK0BmoIVxI4Lr34m1aM6gNlSf7htx92eDlQXlkJ3ztEFQcd4vYo7DFB1A5p2vijQE/IsZHNNNQrnIdDg8H27j2Po0sKjf9g=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777328188; c=relaxed/simple;\n\tbh=PGxVViMhHB03sAijAlxNGF7mgYEJwbY2rwD26gbYrHs=;\n\th=Mime-Version:Content-Type:Date:Message-Id:To:From:Subject:Cc:\n\t References:In-Reply-To;\n b=GvO1ZToLKjGNXbWNcls3xIaQaZmEoRMksM0cTGYeUxmMoyqGunojToaN21pohTYuP7uUy5KijXohO91+J6HZ0rFIjFti6NZlUOjd/H/rW3prruJaoMisrCpy4MfcTtdKFFR4ce+objgPrNqEhKqVO7Nrm/dxBvQacik0gthQcjg=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=gCSOdWN5; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1777328187;\n\tbh=PGxVViMhHB03sAijAlxNGF7mgYEJwbY2rwD26gbYrHs=;\n\th=Date:To:From:Subject:Cc:References:In-Reply-To:From;\n\tb=gCSOdWN5D78SXVP+wRiSah70WX8vRhFWzTMxldjJDoEzDh6ADKZ+QjTRz0r2SqQ5W\n\t jsnRgoXUP5yPTSYZ/Dv68rQFrSs/MnSnT7/KCoxEiJZe0882jXgk2PPazeiNotutr9\n\t CGFSPYFy3CIZf7rdd0Xky9gMP+hXeMZtsd2CPmIvGyVi6JJV6AO/IPHpFvXsagP9za\n\t AbTQbRn0Wn7ykefDrvhM3Rqlvl/Bb/uMpFVzoyYbXCtnA/FzlV5XljmA88Wr1ORiRq\n\t ORqJK2J+jrYSlZFhzq4oLqrwuQh5tUOWOiMJTxC4U774y57AvoJEzxd0ThPOzhGvWt\n\t ZBbqvlZ6TwevQ==","Precedence":"bulk","X-Mailing-List":"linux-pwm@vger.kernel.org","List-Id":"<linux-pwm.vger.kernel.org>","List-Subscribe":"<mailto:linux-pwm+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pwm+unsubscribe@vger.kernel.org>","Mime-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","Content-Type":"text/plain; charset=UTF-8","Date":"Tue, 28 Apr 2026 00:16:20 +0200","Message-Id":"<DI4A9AFPGL3D.16M7U97LU7B4R@kernel.org>","To":"<gregkh@linuxfoundation.org>, <rafael@kernel.org>,\n <acourbot@nvidia.com>, <aliceryhl@google.com>, <david.m.ertman@intel.com>,\n <ira.weiny@intel.com>, <leon@kernel.org>, <viresh.kumar@linaro.org>,\n <m.wilczynski@samsung.com>, <ukleinek@kernel.org>, <bhelgaas@google.com>,\n <kwilczynski@kernel.org>, <abdiel.janulgue@gmail.com>,\n <robin.murphy@arm.com>, <markus.probst@posteo.de>, <ojeda@kernel.org>,\n <boqun@kernel.org>, <gary@garyguo.net>, <bjorn3_gh@protonmail.com>,\n <lossin@kernel.org>, <a.hindborg@kernel.org>, <tmgross@umich.edu>","From":"\"Danilo Krummrich\" <dakr@kernel.org>","Subject":"Re: [PATCH 02/24] rust: types: add `ForLt` trait for higher-ranked\n lifetime support","Cc":"<driver-core@lists.linux.dev>, <linux-kernel@vger.kernel.org>,\n <nova-gpu@lists.linux.dev>, <dri-devel@lists.freedesktop.org>,\n <linux-pm@vger.kernel.org>, <linux-pwm@vger.kernel.org>,\n <linux-pci@vger.kernel.org>, <rust-for-linux@vger.kernel.org>","References":"<20260427221155.2144848-1-dakr@kernel.org>\n <20260427221155.2144848-3-dakr@kernel.org>","In-Reply-To":"<20260427221155.2144848-3-dakr@kernel.org>"}}]