Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1007531rwb; Thu, 10 Nov 2022 10:00:52 -0800 (PST) X-Google-Smtp-Source: AMsMyM5ttblZF8bpVXn0xCtj3UpRGdB978NDfp3YXsxT8s6uxl3oIAtJT12VFc20OX2KzC5HfnaM X-Received: by 2002:a17:90b:1e0d:b0:213:ae0:fcf8 with SMTP id pg13-20020a17090b1e0d00b002130ae0fcf8mr66767480pjb.189.1668103252539; Thu, 10 Nov 2022 10:00:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668103252; cv=none; d=google.com; s=arc-20160816; b=oTrUPWNPpgE7JomQSx3frBmrEHfntSOnTFUWmVXJWEYwkohlhqxfnlQKtwn1ctjwCQ qyeb3//c24Njc1PobTiB5tEsb9P7p+l1PhsfYk7A1cn39bW6gxhzKonXlMRUlc1+qskY X56ok+welaXPFsk906FcoskyWds/3Ai8m0Up8u9mtfTT3Tbd74eLyeW468fAkazefOnS prTgASEno+aCoVgBs19XYxRHMqBwFkdY5kp2uOgnoFZWMuMrC8uh7szADB7YkvGaPKql Ll9yZIsgM+rcaj1AGPWdtJGl5S2el9/TxV1dZsf7CxbIovjl//jiskqGNUtl9WEi8mLy icyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8FrNuK0IkU0HL5bgRPrz8xUBzj5CJaBgy53d1Jgff8I=; b=ttvujd7A8/pVe0CnZocPvGoni7Q1Gmk+N0iZy8e/uo0gU6xMom93NPyAdJIPyhxJhN 1aJ90t8G3emg54TIbiZLWMzygBogy2u6CakN6IiGdkhOiuzgFKkWkvwH4j9PgEejbLz6 jZVFbQzQicv+Arilf3ClVzbFsMwkq/MYVn0FLTxBPkQr+LJUMIzR+cuok0KHT4tdI4lR YvQPG7Iqu2Wy9z5JjwHbXFRTHExU/1S+WGE8C1TpwgdI8BqUwqwtGFPTlk7nNqXhUvy1 zS3WemuQ6CiAZyRGSKEBPlDIM/7mZM7op6Yzvfo1g+c6+13cOXe27hRpaIdDGO80g7pw eceQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V1fkxyBu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s3-20020a056a0008c300b0056b8bbfe687si641489pfu.171.2022.11.10.10.00.40; Thu, 10 Nov 2022 10:00:52 -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=@kernel.org header.s=k20201202 header.b=V1fkxyBu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232471AbiKJQoE (ORCPT + 92 others); Thu, 10 Nov 2022 11:44:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232351AbiKJQn1 (ORCPT ); Thu, 10 Nov 2022 11:43:27 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A58E43AE2; Thu, 10 Nov 2022 08:43:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DAF0C61BCB; Thu, 10 Nov 2022 16:43:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 678EEC433D7; Thu, 10 Nov 2022 16:42:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668098580; bh=H8GrOu07IRuGrUGFNBmi30U0LGPQsGBzhM2gPsNjUkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V1fkxyBuVKLqkXCwarbt2nzk2Gmd07/5IZb172x8K6Iy7ZZK0piYHQxGtjJCvFZ8q Egl+ANyi1jtSNOuoAVyMVUn7rSeKu62QUS8uG1yNeqdQ+kDrAWvp82GYOJx0YHKWck lr/e+VWXG4RC7ejtRrDSGpYfNpXSBwAGrMQg7Bnb5C0xO19VpGmFTymLBid3wrPtx/ ZXk7aIs44xhFG4QWSt7kCoxPk9WwPBVZH9uM2K7i/1GcZ2hLuUh1wMR/+dmHhCwbMo F+z3N+/Vf2dX4jP31xl7zMAda7Tv7tuUDo4lJ4/4IG64eaxObhRxbFOYk8xUTftZA2 9AvF7s5SKzNWQ== From: Miguel Ojeda To: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH v1 14/28] rust: str: add `BStr` type Date: Thu, 10 Nov 2022 17:41:26 +0100 Message-Id: <20221110164152.26136-15-ojeda@kernel.org> In-Reply-To: <20221110164152.26136-1-ojeda@kernel.org> References: <20221110164152.26136-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 From: Gary Guo Add the `BStr` type, which is a byte string without UTF-8 validity guarantee. It is simply an alias to `[u8]`, but has a more evident semantical meaning. Signed-off-by: Gary Guo [Reworded, adapted for upstream and applied latest changes] Signed-off-by: Miguel Ojeda --- rust/kernel/str.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs index e45ff220ae50..3aa1a0cb9bf8 100644 --- a/rust/kernel/str.rs +++ b/rust/kernel/str.rs @@ -4,6 +4,11 @@ use core::fmt; +/// Byte string without UTF-8 validity guarantee. +/// +/// `BStr` is simply an alias to `[u8]`, but has a more evident semantical meaning. +pub type BStr = [u8]; + /// Allows formatting of [`fmt::Arguments`] into a raw buffer. /// /// It does not fail if callers write past the end of the buffer so that they can calculate the -- 2.38.1