From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.48.36 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796223745; b=N8+T0658HNwatl6G2CsrkuM00wTi73U+kHOL25sZ1eYJ264hp2HwEzQ13F9OkvA9x4dN pxT7QmbHYU7M8AVzlfPfb6qPkfGXD6uRYUfY3WUV+RJHUfU/efLOuAEl0XLOHhmdR+gtB dTdFCMpB5071LHNSiVAfbi/lKIMOKKJ4HEue/FNnjS97k3mYVgG/1PK+TqVvaGo6iBKzq Yu74zI9jc1x5DP6Uz28nXakUv7/KG84EPw6et6qQKcEDIbWbDm8sxEylIxseQvCsWoXXq Uvn3Cdg4wn6QyJYmgMvWRe/idjlZxT2QXAVPvWQ80qlkKI7hAcmsDIJ6ia4nN9YLhAA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796223745; h=DMARC-Filter:DKIM-Signature:Received:Received:Date:From:To:Cc: Subject:Message-ID:References:Content-Type:Content-Disposition: In-Reply-To:X-ClientProxiedBy:MIME-Version:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=3SnNNgwLGOhd4zP/T/ulkxSbuIZuxQgn/2+23O/c3Ns=; b=YLWsKJX2Zo3HChIgydbr+xohTbTZOoAWyJRtcgz/SLUDgYquZbTQnPDaGE9R/Sj/qT1r Y2VTFR0JNPLFvU008pqs+kRyW5hBXTt654PNevqD8je4xwTwc6TdfiHPeGpc+C1q9+BeT h3rnjrRFPQqHbURJxwvtfQoqFkb/HIlBEO8zFZ5N6BxKZTXI2s84aFixVjlaoN9oEE+An Q5yss2HFXSMEuH/OXY/oJewtix+Ecj+F4KgtZHZjwytLYTeil85i+oFtik36aPCPEufVC xhy9/GZNVIIKlTQn7/AxXJJAuA4zR+XpeE/WpruS9F4rUJUNSW9+k/1G5a6DqlXqccQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=oko6BXwk; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.48.36 Received: from MW6PR02CU001.outbound.protection.outlook.com (mail-westus2azon11012036.outbound.protection.outlook.com [52.101.48.36]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3860606A31A; Wed, 2 Dec 2026 15:02:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A3860606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=oko6BXwk ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cTEUFQgkJD6/qJuTEwJfNmmZ9d5+gM4tOiiKrppsxgMQCept8BRmqS2d6rhOT0ILbFh6CgG62FH3fEjUh7U0xRGpaZlX1hJGdtkLG0nxACUBRhdU6X4Gk5EGB2FEdeRpxqIOBLhCbV8k2pv7Vx+p0XewjYh7POMlWMT+H0m8VnoxFKhHMtu+UCDq9cxRPCAaLwG/oGzQ0zS0jd077spcTTYwT7pC9FpRwJDmm6u5kjF3WYWvSjO1YTzZQzbAEsBrv8fxJBvTfLqAunuf3TIzJ1vA3MzvNNXCkblQ3Pjdhxzee6ikTg/JdvymsHey2LI8tm0tr7Rj41MrmgTV12xlAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3SnNNgwLGOhd4zP/T/ulkxSbuIZuxQgn/2+23O/c3Ns=; b=jou8267IbjhGNS6B4N4Z8uF42rlhkkgW5HO8iE/h3DP5jP8zZbGM3DnWPFfYWI1bRaeK9L7wC9ZF/i1cY/EPoZtMdrwnRQhUeneXadqUpi19I3R0ah+w4k0n5xT+NHBzXDxkWmI58sS/Tm/8itDED3u8GW5XCAh+ni8owVuz/S1jpLEPCbsqbDbB43j0a68sarv5TlDCynJ65mNEircplBkc1MB6naGorKY3fTLY4bRGAlsTfT/rY56PvPlOkovTxfiOE2885KcEY9RcVDitAl2xT5ToRFNi4uUc2LRdk7s8+LLAnXw1jzk7/v/KZ3H2HduTxKh0taIeHOFK/j99kA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3SnNNgwLGOhd4zP/T/ulkxSbuIZuxQgn/2+23O/c3Ns=; b=oko6BXwkK1cqkojDRdZqGHvlgHZvrmTQKstWa7BTIg0EW5lgBv6600ui3q8sRJskl3If5oX3pPSKWxjBvl1SjzMPNIxaliOWxSh9W5r3BuLLPeBknduGQmzNkleUk0Vhg3DA6M+SuS4xEAmbYtpMaWtZKcclsaKYJPNFaOYepHUErUNVxVN7gxmZ/8JbdMgYs+IvyVYh8ZeFNB+I6FZx2UCWpseBe41ASKCr8qDXVpChDVhc2IptzUs+wX6UeYQuvzpoCgKd0yxoZk9Zdfv93VgXYYdQIOpYjPHCPjoq0UkO7PHQaE7stwf9rME2qclaQB6vijcLCsK7KRIPmqTBow== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SN6PR12MB2814.namprd12.prod.outlook.com (2603:10b6:805:72::33) by CH3PR12MB8657.namprd12.prod.outlook.com (2603:10b6:610:172::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Wed, 2 Dec 2026 15:02:09 +0000 Received: from SN6PR12MB2814.namprd12.prod.outlook.com ([fe80::9a18:413c:9702:8f59]) by SN6PR12MB2814.namprd12.prod.outlook.com ([fe80::9a18:413c:9702:8f59%6]) with mapi id 15.21.0662.012; Wed, 2 Dec 2026 15:02:09 +0000 Date: Wed, 2 Dec 2026 10:02:07 -0500 From: Yury Norov To: Vitaly Wool Cc: Andreas Hindborg , Jens Axboe , Yury Norov , Burak Emir , Boqun Feng , Alice Ryhl , Miguel Ojeda , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , Onur =?iso-8859-1?Q?=D6zkan?= , linux-block@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Belousov , "Claude Opus 5 . 5" Subject: Re: [PATCH 1/2] rust: bitmap: add BitmapArray Message-ID: References: <20261202092332.136789-1-vitaly.wool@konsulko.se> <20261202092332.136789-2-vitaly.wool@konsulko.se> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261202092332.136789-2-vitaly.wool@konsulko.se> X-ClientProxiedBy: BN0PR04CA0094.namprd04.prod.outlook.com (2603:10b6:408:ec::9) To SN6PR12MB2814.namprd12.prod.outlook.com (2603:10b6:805:72::33) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR12MB2814:EE_|CH3PR12MB8657:EE_ X-MS-Office365-Filtering-Correlation-Id: a43c15c1-b0aa-44ac-6551-08df50853d0b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|10070799003|23010399003|366016|6123799006|4143699003|6133799003|18002099003|22082099003|3023799007|11063799006|56012099006|261028144727099003|261026121527099003|261026140227099003|10067099003|261021121427099003|261022105027099003|261102123227099003|261009223027099003; X-Microsoft-Antispam-Message-Info: 4th2lH+R8EJ2C/Fj1ecaWx3EcObSJwPDjln098L8imwQU6sDIMYV8vvm8eaYPISgXEXelCj/GxTwVkJ6uUogeExsTyvU641FRj4aj2yPCMllDGdAdtaDAwCUid9a/INALYZuIhZ5bWpxF5+bnW1wQ8YY474Xo5XLD6s5nwNbBZ1MsEyyp6dELjn3Sg0E9dgc5vJ9fArBid+SA39RT4aB8U63dbv0PG8Ql28hvbpJKU8hEz5pmeN7utLy23/wUba5xd26MH5IoYf4tEhvDGCid0V746zGx0dIeyUlCljxqTaRtTzUv/DXxzTFq+2iY/uvLcQ69nN/bbeAHRUmd1QW0MjG1YpJBNoDJOqaDOX/f1TSabCkn0IDdFcZBhxtz/rTCzpvj+EJScwQpAuta7m0IEB2+x9Q56QeF50YCYKDZXduEWQYNUnsdTfEUGoINcsueeTnPhGCH7c+0Y9Fv4HC0PBz6T923pa86GTgA2gi8Pp+48r6ufzUd3Q3rUVbSLEKByLziPeVkaUdCzB+6Fi2kSxratRfvbU9EsHSCE1InmxphJosm/mjSKT0NtjWhd+xVX+l4TtxmCJ6RbnoeOBmiK2L5W0oMQ3E6/8p5sqZasjnwI1+zTTk2tIecyJNseBSWjEdM8023QR3iqtIYnSC+LWp7iImwa5OdG4H76v4ows= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2814.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(10070799003)(23010399003)(366016)(6123799006)(4143699003)(6133799003)(18002099003)(22082099003)(3023799007)(11063799006)(56012099006)(261028144727099003)(261026121527099003)(261026140227099003)(10067099003)(261021121427099003)(261022105027099003)(261102123227099003)(261009223027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?rCgqEIbgCObZpfYxWd9joS66Ut7BI9Z7blrNyyqCkJf5f59R7dr7uP8L2OLY?= =?us-ascii?Q?XbpQwLcXbCBUBuEktCz90v8ST8PqrZwcxRbxPt/yla3JXL38skrJkvjWVKPh?= =?us-ascii?Q?9DP1SusghrrOiAftNmzjUp8VkeDQ4XxYXaeaDneL40yFdijFKBWYQOBMfz0J?= =?us-ascii?Q?1gfyoLX0P3zmE4d66RLhv8Hew+8Rci5tMTaf9vHc+yy62g2hdDnmsF3C+9ki?= =?us-ascii?Q?xaFvOBEtzRSIW5t5YJUXOuW110cxSc3K4F0eNvO7y+rFGW33AdPqo8MgGVQ+?= =?us-ascii?Q?lpt3T+4qKjdSXU4P2UIBKtsPhS1q4AKrphAesWtUVWgMGh3mImN8baRDiUcZ?= =?us-ascii?Q?SHNyCkKgPSOKyoPVrn1xjABzSSJeXNqteBq4gv5uhL1LgMhOkaWF/frOmrhN?= =?us-ascii?Q?5BcFhG6SbcgL+xPYeAn4rSWNi0+YwI+zc9vodq7CTvQCMAgzO0QKTCh9r1rL?= =?us-ascii?Q?yCtaoxNHCiAlgA2uQvb3m84nvaK+aITyxJWkPVZ2GKoQ1ZnG+o8Cf7VNUy7k?= =?us-ascii?Q?EjqrrW4iwq0FLweYkjskbzZhTyRPEVGxRUvi6cSwUKpId1pkNwE+Bo0DfLcX?= =?us-ascii?Q?T2U1FJnfxU96WnpuqLhivbJMDO9At3lgu0CQeDUUZaxm5cvwuIRD90+I0Mpr?= =?us-ascii?Q?UKOcElf2litNgftA5eTOjgJYnJiJy9lXh1p6RTij72y1jX4fp3Jp3+w4LvXl?= =?us-ascii?Q?MistmqJ177MooGHIVpTrdEU9X0Pkk0SjHtHR04Mc99E0ShT2LN/ZScWpeNOZ?= =?us-ascii?Q?C6euDgbjy3u1FOF2mXWehervJYag9/cZ7CvZXd/eECf0xufdnJuz31Y3WQ6X?= =?us-ascii?Q?zGxw5u14aPdJgua/hfM2IiyVGOh8x7MouCGsd1admeCdAx1bOVz5oJ0I7QoK?= =?us-ascii?Q?iYp6tbsKIXHjhWCiQ56aFkAib6veNLmvplVcIp9jJ+llisXI3B39Eckz3+Vf?= =?us-ascii?Q?R+EfHE+c3s4Us9VcV+MUZ4uPdvqwK/PwRn7HEfeSYWioWqgVmKwwGIUWI8M+?= =?us-ascii?Q?YSJI5o4ECpWbt+wU0dyhr1mpRy+k0NfQ0s7kqaj8CbkiUYRgv7LQY+KCkYlR?= =?us-ascii?Q?J3kH/QmPlTNQabdTl3O1F2XuRSk6h4F5IdApBf/ct8FDjK8A2pzTASno6/3+?= =?us-ascii?Q?N15blHVBkTmjkqK5Gg/Kc19OYcpcSK4yHIJpX/a0tzkctMwL5fs6Q8bGnF37?= =?us-ascii?Q?Pp4/6H7EoYRxaEiJistefNGmLu+4orJMrusopuPz7NP8J4MzrSQlykk8vUu2?= =?us-ascii?Q?afhhMQae3MO3oqKCjjwuoiDaDw86iv9m4nwoDZ6TOLANQCu5Z+rBqWuCyn5I?= =?us-ascii?Q?joUQxZUWpQPWddZJV66Pjip7TPiU4mzbkNiRW+O1Su0cjt9Oj5zJHu91EVM3?= =?us-ascii?Q?UsZTnAlU68CI30PMWlm58156xxsZ+FVT2uy/f+UVNCtFGq2W/e3siOL6m72T?= =?us-ascii?Q?s84b7LhyyzZXMq4shiRq7yYc2P7jKyXoBau3m6vHoTGm9kCrDjfJQ6EOTKrv?= =?us-ascii?Q?qQ0EPjKKj45l0OxLEuD+VVFpo97l+gegkfMtDDIpEveFXGWNkjotDCrySLhz?= =?us-ascii?Q?Y2QeKVLov+sS73AsRqHL0dvieHqwSVVU/SNCNzC75THrHqiONQCSiNJ0JWhX?= =?us-ascii?Q?HX6rDJOktPINr/eDnyLEJx1t+9Ky6I1MorqBDO71n3b9rhyh/ZYvsRJI6U8o?= =?us-ascii?Q?cDqgGLiWLyxk63LggPr8SSktzmDSvINLECbSo05fdyoOxXqxKDXrytFIuK5q?= =?us-ascii?Q?vV4SRwjJvoOo7wBvjl7ATptudpDFHkmVc5h2a27Qk2Gycynw6Nnq?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a43c15c1-b0aa-44ac-6551-08df50853d0b X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2814.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 15:02:09.8195 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OFDxc/2RNCc5sm4jFrppqy6TfWwii7dvlaNMN+Dsumr+1ynsHf+bUJV0W9KoFUGzZ6xulj96UjRWX9Cd7yx4bg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8657 On Wed, Dec 02, 2026 at 10:23:31AM +0100, Vitaly Wool wrote: > A `BitmapVec` keeps up to `usize::BITS` bits inline and allocates its > storage with `bitmap_zalloc()` beyond that. A bitmap embedded in a > structure that is allocated anyway, with a maximum length known at > compile time, then needs a second allocation and a pointer to follow, > or `unsafe` code that wraps an array with `Bitmap::from_raw()`. > > Add `BitmapArray`, an owned bitmap of up to `WORDS` words of > bits stored inline, which never allocates and dereferences to `Bitmap` > like `BitmapVec`. BitmapArray is a tautology. Bitmap is already an "array of bits". So unless you're talking about 2d bitmaps, the name is wrong > Signed-off-by: Vitaly Wool > Tested-by: Igor Belousov > Assisted-by: Claude Opus 5.5 > --- > rust/kernel/bitmap.rs | 91 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 91 insertions(+) > > diff --git a/rust/kernel/bitmap.rs b/rust/kernel/bitmap.rs > index 610d565535cc..7d7bd40e2e2b 100644 > --- a/rust/kernel/bitmap.rs > +++ b/rust/kernel/bitmap.rs > @@ -8,6 +8,7 @@ > > use crate::alloc::{AllocError, Flags}; > use crate::bindings; > +use crate::error::{code::EINVAL, Result}; > #[cfg(not(CONFIG_RUST_BITMAP_HARDENED))] > use crate::pr_err; > use crate::ptr::Alignment; > @@ -320,6 +321,96 @@ pub fn fill_random(&mut self) { > } > } > > +/// An owned bitmap of up to `WORDS * usize::BITS` bits, stored inline. > +/// > +/// Unlike [`BitmapVec`], it never allocates, so it suits bitmaps whose maximum length is known at > +/// compile time and that are embedded in other structures. See [`Bitmap`] for available methods. > +/// > +/// # Examples You need it to embed in a structure? Why don't you show how it works in the example? Maybe even add pahole output to convince me that you did it right... > +/// ``` > +/// use kernel::bitmap::BitmapArray; > +/// > +/// let mut b = BitmapArray::<2>::new(100)?; This is simply wrong. On my 32-bit box this wouldn't work, for sure. Check how DECLARE_BITMAP() works in C. It doesn't take the number of words. The same holds for every other bitmap function. That's on purpose, because one of the main goals of the API is to decouple the data structure from machine specifics. Just look at the implementation and see how much work has been done to keep bitmaps working smoothly across the different word lengths. Sorry, but strong NAK. But not a NAK for the idea of embedded long bitmaps. I would first experiment with something like Bitmap<100>. This should look like; struct Device { my_bitmap: Bitmap<100>, } And from pahole perspective, should be the full analogue of struct device { unsigned long my_bitmap[2]; }; on your 64-bit machine. Thanks, Yury > +/// assert_eq!(100, b.len()); > +/// b.set_bit(3); > +/// b.set_bit(99); > +/// assert_eq!(Some(3), b.next_bit(0)); > +/// assert_eq!(Some(99), b.next_bit(4)); > +/// assert_eq!(Some(99), b.last_bit()); > +/// > +/// b.clear_all(); > +/// assert_eq!(None, b.next_bit(0)); > +/// > +/// assert!(BitmapArray::<2>::new(129).is_err()); > +/// # Ok::<(), Error>(()) > +/// ``` > +/// > +/// # Invariants > +/// > +/// `nbits` is at most [`BitmapArray::CAPACITY`] and at most [`BitmapVec::MAX_LEN`]. > +pub struct BitmapArray { > + /// Storage of the bitmap. > + words: [usize; WORDS], > + /// Length of this bitmap. > + nbits: usize, > +} > + > +impl BitmapArray { > + /// The maximum length of a `BitmapArray` with `WORDS` words. > + pub const CAPACITY: usize = WORDS.saturating_mul(usize::BITS as usize); > + > + /// Constructs a new [`BitmapArray`] of `nbits` bits, all clear. > + /// > + /// Fails with [`EINVAL`] if `nbits` is greater than [`BitmapArray::CAPACITY`] or than > + /// [`BitmapVec::MAX_LEN`]. > + #[inline] > + pub fn new(nbits: usize) -> Result { > + if nbits > Self::CAPACITY || nbits > BitmapVec::MAX_LEN { > + return Err(EINVAL); > + } > + // INVARIANT: `nbits` was checked above. > + Ok(Self { > + words: [0; WORDS], > + nbits, > + }) > + } > + > + /// Returns length of this [`BitmapArray`]. > + #[allow(clippy::len_without_is_empty)] > + #[inline] > + pub fn len(&self) -> usize { > + self.nbits > + } > + > + /// Clears all bits of this [`BitmapArray`]. > + #[inline] > + pub fn clear_all(&mut self) { > + self.words = [0; WORDS]; > + } > +} > + > +impl core::ops::Deref for BitmapArray { > + type Target = Bitmap; > + > + #[inline] > + fn deref(&self) -> &Bitmap { > + // SAFETY: `self.words` is an initialized array that holds `CAPACITY >= nbits` bits, > + // `nbits <= MAX_LEN` by the type invariants, and the array lives as long as the returned > + // shared borrow of `self`. > + unsafe { Bitmap::from_raw(self.words.as_ptr(), self.nbits) } > + } > +} > + > +impl core::ops::DerefMut for BitmapArray { > + #[inline] > + fn deref_mut(&mut self) -> &mut Bitmap { > + // SAFETY: As in `deref`, and the returned borrow of `self` is exclusive. > + unsafe { Bitmap::from_raw_mut(self.words.as_mut_ptr(), self.nbits) } > + } > +} > + > impl Bitmap { > /// Set bit with index `index`. > /// > -- > 2.39.5