From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CA18E199935; Sun, 7 Sep 2025 17:17:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757265453; cv=none; b=EeINNkp6MFZd4wcfWecEMxLVXOK6QbQldy8Xk/U7G127rA8lvg1fb47Ph+xtEEevZHq7rkjEFzE3sdTW149JsfZa00MX3au4DvEJdg4AtNGreqqazfBv1U4sXCW/utQl9IpJnDQCyQIJ13vwskD/iZZsIJXSvW6Jv/pIJu70Um8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757265453; c=relaxed/simple; bh=oLlWLQqL2NNjUFOximcNDI+64aI6fOXdL6hqqNDCVls=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:Cc:To:From: References:In-Reply-To; b=kVw3thJOCOnKq20/NHzY9fnFRvJ8tp60zP7z943mtYauYfrPWygJIcmIn93P/udmJtWYsw65pGp9THoZ+UY2OQs9aZ+NnMwIhj+8Xo706EXqFY1VsTpGSQlbtDrjDlcm5Xd/1+/VQAVc9SsgYOJ0TKDQAj3WpO2II1DPzj/1lvk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DvcQCEIs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DvcQCEIs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E99EC4CEF0; Sun, 7 Sep 2025 17:17:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757265453; bh=oLlWLQqL2NNjUFOximcNDI+64aI6fOXdL6hqqNDCVls=; h=Date:Subject:Cc:To:From:References:In-Reply-To:From; b=DvcQCEIswbUW2x3bTY69yRDiqJWXwIGbAmVy6KnHWZfBzPA9V+2gKvgq7bCNEtw0o wZ6xzglrmiaCr77GbULJObmrHJXvA5nIb/aRD5mun4qfeElW76ephBN697ybtZ19lI qY+qTGeO3cWYOsiuGH644sbTy+lHVwlN4N86W5D9CrBVNunpVXJTALzobLMN77ZBXH itOe6W5x3pttHFpOVrp+LOS8cIuPvekRBotFA1qf34NfNKjhHNu9Aa/ghk4xQd3+NB 1rl0lCw/HR7bkfqSqRgZ96FJeUDMmQnUHa+Bds3sQ4ILqaRZHI5hzviVQ1aKTOIlmi u+NE2F9JXiNsg== Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Sun, 07 Sep 2025 19:17:28 +0200 Message-Id: Subject: Re: [PATCH] rust: pin-init: add code blocks to `[try_][pin_]init!` macros Cc: "Miguel Ojeda" , "Alex Gaynor" , "Boqun Feng" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , "Fiona Behrens" , "Christian Schrefl" , "Alban Kurti" , , To: "Benno Lossin" From: "Danilo Krummrich" References: <20250905140534.3328297-1-lossin@kernel.org> In-Reply-To: <20250905140534.3328297-1-lossin@kernel.org> On Fri Sep 5, 2025 at 4:05 PM CEST, Benno Lossin wrote: > Allow writing `_: { /* any number of statements */ }` in initializers to > run arbitrary code during initialization. > > try_init!(MyStruct { > _: { > if check_something() { > return Err(MyError); > } > }, > foo: Foo::new(val), > _: { > println!("successfully initialized `MyStruct`"); > }, > }) > > Link: https://github.com/Rust-for-Linux/pin-init/pull/84/commits/2880a9b8= 98336e2d54f80715f00ce00f21f74d2f > Signed-off-by: Benno Lossin Tested-by: Danilo Krummrich