Message ID | 20240812182355.11641-24-dakr@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52B1BC3DA7F for <linux-mm@archiver.kernel.org>; Mon, 12 Aug 2024 18:26:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DFB9C6B00CC; Mon, 12 Aug 2024 14:26:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D9E476B00CD; Mon, 12 Aug 2024 14:26:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C3E8B6B00CE; Mon, 12 Aug 2024 14:26:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A6E7F6B00CC for <linux-mm@kvack.org>; Mon, 12 Aug 2024 14:26:18 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5D779C011E for <linux-mm@kvack.org>; Mon, 12 Aug 2024 18:26:18 +0000 (UTC) X-FDA: 82444423236.25.8834702 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf02.hostedemail.com (Postfix) with ESMTP id 5BD248001F for <linux-mm@kvack.org>; Mon, 12 Aug 2024 18:26:15 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=K7jG6z+3; spf=pass (imf02.hostedemail.com: domain of dakr@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723487084; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=53m9V8AoGWStcovhU1hAENmzANHwIczK/XyCtNmkf3I=; b=tC4McZMFAD0JRDoeQvsIRxKA3H1OM0qwoGRhkzhwSanja9FSTukTY/fpAkVFhmkdyXnUbV cCg15o9XleYy3cYdGdwz+CmMOLFg8XQ27r4zGmihjg3Pn0iDBlNORtHA7nnVjBu+wee39I cZg6YpxtoYHz2f9VImdiSXXf968U3P8= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=K7jG6z+3; spf=pass (imf02.hostedemail.com: domain of dakr@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723487084; a=rsa-sha256; cv=none; b=g8DrKbuOkK/ctXddy72BAnEzB6fkzpEuG2ZV+vFmeHAlt7S03xPbUUrLI1GowGsXo4ebm5 dMxp1o+t7VeKG8ahdDr/tH/w7fXp0MSFAMFcbvKrdGh+tSxaYpqj+G1kLwgTta7RvT3mRf wThNmrtA4UiDOE3MydjHDkf6EwVCRuE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 70055CE0A6A; Mon, 12 Aug 2024 18:26:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD867C4AF09; Mon, 12 Aug 2024 18:26:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723487172; bh=SxIIf+SSSfq/ByqB+qb2+RtiJyH5BPK+PFBZGcm3qDM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K7jG6z+3m6ZxFsGXWBawNolBPj9HDFiJ+jJbgWgSYU/Bo/BLz6Pp3ReAsC31yciEI RmHM57eHf3FgMPfF4E0cuk0P3mTZJe1gWJuKYbnyDPUaA04ll0yzwsvXSaCJ3BlBck WyO81o6zRTQMz831jpTuwtl4Jh9LVcLBhNeAGQfpu9rcJHNTSEEJNYF71Go5BM5bX6 S2y4NTJ1ealfzYlRIIGKlxwSAwRHoeKbSk1QtVAoFmRDWgr7GXsHjl643pPGylZTW3 RFedq47VIXKszDfEcxP1PJkcuDHYtpF7oC2Z4s6hqB/DvMsvDUMO8neVPx1WuCqKbp g1ggCMovo94Pw== From: Danilo Krummrich <dakr@kernel.org> To: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@samsung.com, aliceryhl@google.com, akpm@linux-foundation.org Cc: daniel.almeida@collabora.com, faith.ekstrand@collabora.com, boris.brezillon@collabora.com, lina@asahilina.net, mcanal@igalia.com, zhiw@nvidia.com, cjia@nvidia.com, jhubbard@nvidia.com, airlied@redhat.com, ajanulgu@redhat.com, lyude@redhat.com, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-mm@kvack.org, Danilo Krummrich <dakr@kernel.org> Subject: [PATCH v5 23/26] rust: str: test: replace `alloc::format` Date: Mon, 12 Aug 2024 20:23:09 +0200 Message-ID: <20240812182355.11641-24-dakr@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240812182355.11641-1-dakr@kernel.org> References: <20240812182355.11641-1-dakr@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 5BD248001F X-Stat-Signature: m8h3uo6aqre6kwqur563eq14z7p8p46c X-Rspam-User: X-HE-Tag: 1723487175-594623 X-HE-Meta: U2FsdGVkX1+HD/G3z+F3hPjGx4NPqyoHd8Zo4jhBgiXnc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jNhIYOOXdOpXfgn1IZuazfBB/y6r0V4W5pqo/3bpeyg8xJFVXDvql4ngTvIoo8VWgGQEwUars0X4ZZQ75js5Pv9poxAzxZTcLm4x/LRWyzIuhN5Gu/zmnPb+QR8GITvlvWWfFJJn3xVVKsKPFpI/EeG+JhWFFOFGR7g19KTlgMPmuuqijWUdpbF4H1dokp98E18= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
Generic `Allocator` support for Rust
|
expand
|
diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs index 209ad1bb1a49..726329530338 100644 --- a/rust/kernel/str.rs +++ b/rust/kernel/str.rs @@ -523,7 +523,28 @@ macro_rules! c_str { #[cfg(test)] mod tests { use super::*; - use alloc::format; + + struct String(CString); + + impl String { + fn from_fmt(args: fmt::Arguments<'_>) -> Self { + String(CString::try_from_fmt(args).unwrap()) + } + } + + impl Deref for String { + type Target = str; + + fn deref(&self) -> &str { + self.0.to_str().unwrap() + } + } + + macro_rules! format { + ($($f:tt)*) => ({ + &*String::from_fmt(kernel::fmt!($($f)*)) + }) + } const ALL_ASCII_CHARS: &'static str = "\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0a\\x0b\\x0c\\x0d\\x0e\\x0f\