Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1424856lqd; Thu, 25 Apr 2024 15:35:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV9xAn+QA8WYwqZWerRCzLtf48PskxTCHX1nBviERM39lEb5HjPrXtOflkrrKqqQQLkGx8URKHVifHOUHPxelohnd4DzqO3NKOdU8uIxg== X-Google-Smtp-Source: AGHT+IFFYaLyt9XFZBoFHs/i/EP1rHH8M37hqZHjRJbUtc10fX5X2ZLxHGTGL0rsvQwcugOCTxcq X-Received: by 2002:a17:902:ed13:b0:1e4:24bc:426e with SMTP id b19-20020a170902ed1300b001e424bc426emr986051pld.28.1714084521891; Thu, 25 Apr 2024 15:35:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714084521; cv=pass; d=google.com; s=arc-20160816; b=RPInT2QcsChnOV5Oeq/6qyZ5LL12K3w/FWg+wcSFWmxgxNR5/8HQtSzJTw1Ja6+EMy eom+3s8cW/A8Dx50eWnHkzu8BS+HJCrl737c/uQhrUuCzdab1ReLQfIEFUWAqWnXdVto 7PPozcgeVwYcMAIgbVbAl5Q3KPIw7kC9Bu/s0+yDPFDvqsxPO+wNz+63A9nomWjWKnou 0jn7pRc0SczvMvhX/tuHEQuB+NM8wuVGhFUdfBEAS4F00vOMmk+h23UHWVyU3UZ83umg npw4+YkwcKkMwP9yMMp8aiDh7JBZhMkk7QlZmtI+Dn6GgEbq8NKv1N51NT/3/wxOx5hf gIyw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:feedback-id:references :in-reply-to:message-id:subject:cc:from:to:date:dkim-signature; bh=ssR1QDbWXYl4zvVV2r1hbcZe90jbbir7db4PC/qkIxw=; fh=jz9ZYdkZU3gmm8weL7yql0hVHDdlmm49R0ERliAl9tY=; b=HDl1n3KARCgtDOxwN7Tm5/DhiqTpdtcu5Kik6tPZsZsoiuUZN98GJZAwRTI1GvH5r/ J65acjFgXGKut9V9sgxn5vbLLnx7FK6ebJm19dq7Xb7pfxm2DsAp4nsoKprlwJGaUlJg W06uwWwetNUe/+Ict6fzDbbBPDPwFCGsbILC62ZlhzLZhFHp4oxqzpSnOcELIvxzEAnB akRvDjnby8twfMyEFOjxqxhHLCK7KqQcAZ2VflsxB6Nx/pTIa47fBcMDNey9RcnDisSQ cumkKWrzXW6sQ2hyIa+rkATgZK49vSoEVwCuJUa+6G+2CjM5pYiYhNm+8hpPTlWLrHnb 6qog==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@proton.me header.s=xoici6hpxjgnho75p7nsvwzjhm.protonmail header.b=SiqyAVSj; arc=pass (i=1 spf=pass spfdomain=proton.me dkim=pass dkdomain=proton.me dmarc=pass fromdomain=proton.me); spf=pass (google.com: domain of linux-kernel+bounces-159288-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159288-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id u1-20020a17090282c100b001e4e4f5a487si13549351plz.132.2024.04.25.15.35.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 15:35:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159288-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=xoici6hpxjgnho75p7nsvwzjhm.protonmail header.b=SiqyAVSj; arc=pass (i=1 spf=pass spfdomain=proton.me dkim=pass dkdomain=proton.me dmarc=pass fromdomain=proton.me); spf=pass (google.com: domain of linux-kernel+bounces-159288-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159288-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5F664B25338 for ; Thu, 25 Apr 2024 22:08:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A5A6159594; Thu, 25 Apr 2024 21:57:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="SiqyAVSj" Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) (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 58198152526 for ; Thu, 25 Apr 2024 21:57:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.22 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714082224; cv=none; b=gZ6fuIiImhTaVuGw2MwcGX0VzpeFOxP2bFoICJKbffE22vqNQSUloausbJ8iZkWxUzdWChXPmByA3T2eb+K3QsAUfFcOGoqIbZmwbBKFuUica8NIx+UpK1hys2vPC+ssrTPAgf55jm94vVxhmnJWamJUj13gx/Lb1EX+va1uHyY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714082224; c=relaxed/simple; bh=2AC9sknLoDsBrHZj6JPOUgXsHl0ckGSbKEILsuBcFn8=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=T0zGLi1eOxaaZ0BRQBMHfa87MPtEs5pYqP6CyVjDSmCpIZ+M56+Mnbd9iMkyCpt4Zo3wn8YtLcx9klPRgsvHl+5dCYd50olm2kMbyJs8UzZrCDRpziA8JYKNTbS9m2bK0oWxm/W/Vl3Pu6vMjFUM4K9JFa83R7nBF4e2Z2Aidfg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=SiqyAVSj; arc=none smtp.client-ip=185.70.43.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=xoici6hpxjgnho75p7nsvwzjhm.protonmail; t=1714082219; x=1714341419; bh=ssR1QDbWXYl4zvVV2r1hbcZe90jbbir7db4PC/qkIxw=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=SiqyAVSjPIZTVEUW7Y+8oEW/BRlMJBDBE86ccDZJeHaExhb9IPkM8YozY6go0x13h W/s9+m85Ibcwodaw/VIWgzEj51Y5I2Eu9YqSzdZsyjcbI/0gy3Pa1EBEroAW3FkeEf u9Qg4hMbMnzpj9xP7GzoHCTOCSXfwodJpDFfuC3RC9wl4AEcOPWoKVUL8SE+XU+1p6 2KLmWzqMDSbaDctlxAyDQlPmuqmlKetc7JvI9wU2HvLlNddQ956r9EGyzgy17numSU ldE6nEkbebDpV+WZSoL4NoYfoj2Aw7KEzpsz6iPE6r6JkAN5sWftXBuqLLH2fP4uzi bEva6PwM7ZNMg== Date: Thu, 25 Apr 2024 21:56:54 +0000 To: Matt Gilbride , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , Greg Kroah-Hartman , =?utf-8?Q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Christian Brauner From: Benno Lossin Cc: Rob Landley , Davidlohr Bueso , Michel Lespinasse , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/5] rust: rbtree: add `RBTreeIterator` Message-ID: <85fdf6ae-3838-46ff-828f-3179cbad1d30@proton.me> In-Reply-To: References: <20240418-b4-rbtree-v3-0-323e134390ce@google.com> <20240418-b4-rbtree-v3-2-323e134390ce@google.com> Feedback-ID: 71780778:user:proton X-Pm-Message-ID: 8f60004c9bd63e1dddb642f104a09560ba8a6505 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 25.04.24 23:45, Benno Lossin wrote: > On 18.04.24 16:15, Matt Gilbride wrote: >> @@ -373,6 +416,56 @@ fn drop(&mut self) { >> } >> } >> >> +impl<'a, K, V> IntoIterator for &'a RBTree { >> + type Item =3D (&'a K, &'a V); >> + type IntoIter =3D RBTreeIterator<'a, K, V>; >> + >> + fn into_iter(self) -> Self::IntoIter { >> + self.iter() >> + } >> +} >> + >> +/// An iterator over the nodes of a [`RBTree`]. >> +/// >> +/// Instances are created by calling [`RBTree::iter`]. >> +/// >> +/// # Invariants >> +/// - `self.next` is a valid pointer. >> +/// - `self.next` points to a node stored inside of a valid `RBTree`. >> +pub struct RBTreeIterator<'a, K, V> { >> + _tree: PhantomData<&'a RBTree>, >> + next: *mut bindings::rb_node, >> +} >> + >> +// SAFETY: The [`RBTreeIterator`] gives out immutable references to K a= nd V, so it has the same >> +// thread safety requirements as immutable references. >> +unsafe impl<'a, K: Sync, V: Sync> Send for RBTreeIterator<'a, K, V> {} >=20 > The bounds on `K` and `V` look like typos to me. They should be `Send` > instead. Oops, scratch this comment, what you wrote is correct, since we treat `RBTreeIterator` as `(&K, &V)`. --=20 Cheers, Benno