Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1145031lqj; Mon, 3 Jun 2024 11:26:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwRFXV9cAuBxMpL+CuXWlH8YnqKmnvjyUsmNOdDkJi0SXDbLA2KLLO0D9NWcEqG4RwnLXRJRyuzuTfdfMYoUtwUjEtBGCJY9IMcYUgYg== X-Google-Smtp-Source: AGHT+IFHdLWua67ChRm5i9eIWpZqITntBzqHsPacDADe9vGyEKa7fvWOvWU+Ts3QXMZdGocrUReT X-Received: by 2002:a05:6a20:3944:b0:1b2:2e3e:42e0 with SMTP id adf61e73a8af0-1b26f2050d9mr12473172637.37.1717439177838; Mon, 03 Jun 2024 11:26:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717439177; cv=pass; d=google.com; s=arc-20160816; b=U2nDTNTu2EZVm/9S2xGm7a6WLdXWbSo3D+ZBQub8jUh6NfAlEXziK+o8vrfW94rmbi mlkwa9074Dd7RLBVKoesKXH73dsI+5mEQYUbxANcSdfSyjfpX1fap/+iRBfki2XMYQUC akUFFvxiRda51Gcoi3jGtbAMRaWh5PD4OLwjdGKf0GZ/m23utRMMfMzqQxUsFz+TJCg0 4XbA16DGwcel8VMNR/rXwIwUhaOLQJVMQkW9qPM5ErF0mOAOLIN9nU1gQ1NwcmlP4WrG 3OB8wWnpBmQwtlXZ2qQBMttnX72yWh06L8jZA5CMqWBqJBq9gJhFMXuGHfwiQARq+KeJ yojA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature; bh=fCFyJO/J5aHagK4bUMQJpa9iUDqH+pER8Q5gFOrJVdM=; fh=cUbDWTA1kZl4A8CGtuSf/dZuBylOoqHlROwiEamPazs=; b=qymhCyKXH7IfskPuT1wbSQq54+XQZj8/uxD4TOzgp4HApkDdfRbshuV8dV0Si2KyKF rAMoMCtSeXJ6mUZaQUx3dwkUqhAG91qJh9x1HsCVsxw02FrCYJZYI/XhWp/+ghw9m3gJ JjMbbZ/iDf1dg4A56OkOESb/c57MW8KR9z0ONzC1/ASShVbOqU4ZpT3pVxofIWj74/CB 7/+2ACFvPdU9O/bs+2WbNWIOiT8gstNosJMskHnRJKtBI2M0y4VeKw3WTIgMprEnOrC6 XXEKdKlVaQUI0G9p3LwBOeb5qScsS+NFMGZM0fEtYs5wTmfIrbPpuTG9YluFtjHl/ERr ifTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="UjOH/eo6"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-199560-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199560-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f63233d153si70662935ad.72.2024.06.03.11.26.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 11:26:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199560-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=@gmail.com header.s=20230601 header.b="UjOH/eo6"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-199560-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199560-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 7EFB9B2342A for ; Mon, 3 Jun 2024 18:26:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 222E71384B6; Mon, 3 Jun 2024 18:26:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UjOH/eo6" Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3D2212F373; Mon, 3 Jun 2024 18:26:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717439166; cv=none; b=Ng7xvCP/k5JUNPgJ3Q2ydL8EyjZI1MLV1oAjkWaFffUn31M6oo1dxsTpHIneZ0jKmJIknbl7Zb0Xr60fbq1aSUnK0G6qEq4pnlRc5zJnBnfPcXjMvLTMU6ySGxFt5m0oYvGguuSwNd4dEiYn2wmnu8gLmMap7G7PaPZFpvgpQQM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717439166; c=relaxed/simple; bh=hjKrTRchuhmFlhG33L5CgE68znNAIqP22uwAWh2alu0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SbZMV49FZby7O6gzfIsxZssAOSJY8RxFg3OOS7j9hmJfhvaCIARxVaMxTxrjrqZsLDnc6sUEA0EFOGi7i0F3E5+znzsV6mAKLoYMPktBtgoxdILPgIYWXvI1M0we/Up/tkt9eoTdTYhLuyCNdr6KGco/F0q+A+7Y0XOETfA+xCM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UjOH/eo6; arc=none smtp.client-ip=209.85.222.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-794ba2d4579so307462985a.1; Mon, 03 Jun 2024 11:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717439164; x=1718043964; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :feedback-id:from:to:cc:subject:date:message-id:reply-to; bh=fCFyJO/J5aHagK4bUMQJpa9iUDqH+pER8Q5gFOrJVdM=; b=UjOH/eo6rScp0bn00jizVx2sNdX+10CFdscxmGc4ESFMpl7pZKFCrCzihhRHbgscoR DsZTELmcJK/kpxkTzywfiidRP1mapsAvIx9dLf6tGd1cNAmahBLv1DfHJRz6tt+9v5lO vjSvjwK2W5RPJkJtRkFjGFJzu1mQ+e24nwMflnOQbP8c9DnkyiGbiVWIExIjFuMQ6/0b 8QWpfXOwM468sRQybDYf3uj6z1f/w5FJotK4lrIvaUj7G/wSmjgaGLS5kcgVM4NBdR6N RSiYOVrR7AV652Y9DDLinedDQWtFc2NAA4Tgm38jgw0+e/iOYNTs/oETeq2FwozaRGQ9 /EFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717439164; x=1718043964; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :feedback-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fCFyJO/J5aHagK4bUMQJpa9iUDqH+pER8Q5gFOrJVdM=; b=LMRfY4GCyeE52oNeljQIp+XSJOxsNli0RuEp9Hsva675JcMWCz2F57UD/iCI7bcEmo 18BxK/y2kl2GUFvwDl3LIfblRxqda81m/cepl+pMFx+U+er5CXvzvGvJptR5q44chx+i Kd+v6/tm+T1RScDXpBKZ6w9+6z7Xk9GU2n8D6hzMqSceQXZP5lwkl9iWZliLc2nx5yyY 1P7B//OyedK6l8TIN7X6bWd869zf2qO0IqLoqFjt4UUvwyVhs0mBYTORVYxt8DQSwDQM arlIxnfMU/ytYgVxDexlP5dqxK1Zg4tjFRlSiwiWiVA0qNEF99jTgrfL2m468WKbb5y+ 7sww== X-Forwarded-Encrypted: i=1; AJvYcCXmIw852IsctKFbLBaMs35DicjYUO/E7Wm6F/haFJ9A+e+v68LyyPLFO4ODH4Z/kxfUQsLwh2jMU56Myk2IY+9qBaOj/z+SqGJPx7c5HHyVqjIfQcXCC1iFV6EWQf1a6upOtOOBMhJmEd2aLJg= X-Gm-Message-State: AOJu0YwopyhB0uzczstYEgK39Mu1sVWzDsJ8wD6jFWWLJpF+WwI/XOxd 0l8IJxDWakyV44nWDbjpkRIPERxRFRtnoxLpT0DLTlqB+gU0CX+g X-Received: by 2002:a05:620a:3bc5:b0:792:a238:4a0a with SMTP id af79cd13be357-794f5c5c44fmr950558085a.1.1717439163670; Mon, 03 Jun 2024 11:26:03 -0700 (PDT) Received: from fauth1-smtp.messagingengine.com (fauth1-smtp.messagingengine.com. [103.168.172.200]) by smtp.gmail.com with ESMTPSA id af79cd13be357-794f31716edsm301547185a.104.2024.06.03.11.26.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 11:26:03 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfauth.nyi.internal (Postfix) with ESMTP id A3F281200032; Mon, 3 Jun 2024 14:26:02 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 03 Jun 2024 14:26:02 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelvddguddvgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtugfgjgesthekredttddtjeenucfhrhhomhepueho qhhunhcuhfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtf frrghtthgvrhhnpeevgffhueevkedutefgveduuedujeefledthffgheegkeekiefgudek hffggeelfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpegsohhquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeeh tdeigedqudejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmse hfihigmhgvrdhnrghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Jun 2024 14:26:01 -0400 (EDT) Date: Mon, 3 Jun 2024 11:25:04 -0700 From: Boqun Feng To: Alice Ryhl Cc: Matt Gilbride , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Greg Kroah-Hartman , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Christian Brauner , Rob Landley , Davidlohr Bueso , Michel Lespinasse , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 4/6] rust: rbtree: add mutable iterator Message-ID: References: <20240603-b4-rbtree-v4-0-308e43d6abfc@google.com> <20240603-b4-rbtree-v4-4-308e43d6abfc@google.com> 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Jun 03, 2024 at 07:52:36PM +0200, Alice Ryhl wrote: > On Mon, Jun 3, 2024 at 7:42 PM Boqun Feng wrote: > > > > On Mon, Jun 03, 2024 at 04:05:19PM +0000, Matt Gilbride wrote: > > [...] > > > +/// A mutable iterator over the nodes of a [`RBTree`]. > > > +/// > > > +/// Instances are created by calling [`RBTree::iter_mut`]. > > > +pub struct IterMut<'a, K, V> { > > > + _tree: PhantomData<&'a mut RBTree>, > > > + iter_raw: IterRaw, > > > +} > > > + > > > +// SAFETY: The [`RBTreeIterator`] gives out mutable references to K and V, so it has the same > > > > s/RBTreeIterator/IterMut ? > > > > Also `IterMut` doesn't give out mutable references to K, which makes > > me think... > > > > > +// thread safety requirements as mutable references. > > > +unsafe impl<'a, K: Send, V: Send> Send for IterMut<'a, K, V> {} > > > + > > > > we can lose the constrains to `K: Sync`, right? > > Either Send or Sync would be valid here, but almost all types that are > Sync are also Send, but the opposite is not the case. So I wouldn't > consider that to be loosening the constrain. > You are probably right. But it's a bit pity that we miss the `Sync` + `!Send` case :-/ Regards, Boqun > Alice