Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1127300lqj; Mon, 3 Jun 2024 10:53:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUOcHA4l+nXQ0HmrY783LUHkOVvlBhX7Okip9HwMDLYLalBltI9M/WucwkPcSu6We/Iuy6CiHg9QJF3etbtg9qHc3wBtvCQL3kMxV3eFg== X-Google-Smtp-Source: AGHT+IESWWpzUtTOtwgO4B8Y4zeB8qADWqkaNuLwDsHROeU2Z4YdIpEqGR85iWaWdK69XDQYqi7n X-Received: by 2002:a05:6358:52c5:b0:17b:602f:24c6 with SMTP id e5c5f4694b2df-19b490b8906mr1313033855d.24.1717437192961; Mon, 03 Jun 2024 10:53:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717437192; cv=pass; d=google.com; s=arc-20160816; b=rMk5YgpNYz54dACBtCGfGPb6lx8j3BqHHYG8JuNUZjHwXXgTPyiV4HuOz9L9K11xeo bH35WPUP0s7KrInZtSzOI//UrIvkNcNa951zzliAytbCnnRwDhNl/ApCNSdFWhEtwOWa ii+6Mrm1C1KpjGi0+yUttK0PDiWCWGUUYlxlwm0c5aCMxt5Igj99c0YNsZ1fYcc95Xna scXb23mRPpk5Tom1FKeO8ugB+tjYSUDSOpg7QaULUTgmbexiNknfzR9zHVFDJKIPhtVK uli17B/Lp3dtYOOPdug5WTk1YQwLlpHhze9s3WgFcQeCxNVEMqbbi4/o8hDX2fwAw5w2 zFbg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=lPGBLbNhfIBiQu1H48kkSjUpEcH7DNN2Yir8GhdMltY=; fh=BcGUw888c8lj4PkMD7RN7LYki2gA+RzwBtnYl5VjIw0=; b=xoFy1Ve8lF7hloc1UfMSjn/3NmB6g6QefoFw8yxpgkuaqlMUfkLerNlTWV+5RiCwjO GPTJO6ZQNcKC6oY9/z8uRUsAZjtowcL2vAvpffYfZZt6Oak2Yv4ykC9QhlpqrkK8P7TA 0Uqn6zpeW5JLxLVjoorr42qvvN7yLJBPs58lzYKSRDgUcMb+5ZFiZ86NQyZY7lQUk00u qkCwgz1NYnU6OylOTyCZ7NLvx6UXJGc4/HqjTs2vKEgHQoKzREDQZ9tsnCLO5l2O9uTl qs8tU0GGKNtrwvAimGDxFXZf7HwHZfYnnd97Nnm9DnZ58EydBwSWjM2f6YVTbxaAjbil h5OQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HzZ5bNhx; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-199532-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199532-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 41be03b00d2f7-6c359e09760si821753a12.309.2024.06.03.10.53.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 10:53:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199532-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=@google.com header.s=20230601 header.b=HzZ5bNhx; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-199532-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199532-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 99E22B23005 for ; Mon, 3 Jun 2024 17:52:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24837137C2D; Mon, 3 Jun 2024 17:52:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="HzZ5bNhx" Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 C6A2B137923 for ; Mon, 3 Jun 2024 17:52:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717437172; cv=none; b=CYh7DOBRDZslvIP6v6s7+zyM8NAGZsgA2rQNfi5taATSLmepmmI8WQ/O2upq+HIV9AG3HUmF1ddCkFZbpTDHpkiHTrXt3n9z5g3vpT22ZqCN52k9/T7OVSXthg3eMz1bnjwi4tQJlubnSC80r4IL2KPt6EQTPg0DFkPTDEm/3R4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717437172; c=relaxed/simple; bh=m0FweyHdPSFpIkTfVZW//pFgcOZYHKV+wSHlMJh9TJs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=IBX9uUrSFh1nwOQDlW7fRB8uPA0t6iHuSm2FSiEUmzoGGoJiovigR4P+NuwuHx9lpFdIbR+BsmKnAHAE8yG88yXcDwg8+8ixOEOJp9XUeIQdNeBQXY1jpLfd5nG/IL593/Pu/eLr50+ZtAGtwxeJRT1KOFGMyxL5DXheKDTTqEY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=HzZ5bNhx; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-35e1fcd0c0fso220486f8f.0 for ; Mon, 03 Jun 2024 10:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717437169; x=1718041969; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lPGBLbNhfIBiQu1H48kkSjUpEcH7DNN2Yir8GhdMltY=; b=HzZ5bNhxn5aGtQkw1VuBDyFvsombNwZoKhNq3jUBc9lsSZ9nbpefvKWd3uj528Cjae diNPSTowrSLSMz8xrHqxZZr+ljdmWil969mX2nEppJW61aDcDfZBFQGoKonQV87umNvc yxIrJTtn7IxRNbsN/Npu/XfunGnhB/nG1JRloGrjtBwOpLvdQVWXbs7pku8HpmSgo8Qt 5Eht74+1RlWgRg9b4c9J2fRJbm9K98LYtYNfhw7kNJMxtW8uWL6JVCKCRf48aUerv3/Y nshXBD8yaT1iC6Y7RJ3tUvCq72enV6JXXIBYCqXlLdh7wAYW31aCEJWAvJIzK+LLOE+K Znjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717437169; x=1718041969; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lPGBLbNhfIBiQu1H48kkSjUpEcH7DNN2Yir8GhdMltY=; b=K/GSclWZEIt/Za6UyXHcSX/PG1l99TSoNQWNyhOotNRqiwyp387fnaVdPxd/p+uLbH 9CyVf5mDgBN/jrBsXrDUTlsv93zg7mg3j9J/SahvZMgtdHTxA7dj83lN60WSS7qFeX9X 62PFVKxbxLqe6iO99EMhKm4yUfifhgn4E1NelC3x+q/CoZI+45LULc8zwIG1dStRYC7y 0jhHDstcu6LsZrrZBLQCDujxGAPBJlYq+xlLiyMcmVFU3+aC4sFC1IOTw/tigPkqD0cC y17jaYTfgfVmu4Awth7NwNWMpCSsc8Rt5oo/C3PjxjPLTeiwgz3aApQ6C4RggaE/ksaU agRQ== X-Forwarded-Encrypted: i=1; AJvYcCWLWPyygC1CSzQPBx11T6/UXrelG5iBpAw9FSH9g+YzoM3P882IiAK7YvZdKUZ0bbkfgUuZx7PtTBgqttS2V8gTTq2RaDPiCyuYZqqd X-Gm-Message-State: AOJu0Yzb9Haim/g4P5xaEU3lg+T9zUhVDXAADDCYVzU0jm7celQFTUYx hSqmzbfOZeb2Z874QHktO0MSKg0eWYZ4pnOHiglOHfvBlHo15nXNIVarNIhwquwv0zNzjyU/L1d nXaxZq/I2PXENSPnAes51NbaZtYs7vPNFDSW6 X-Received: by 2002:adf:ee46:0:b0:355:7ab:2a86 with SMTP id ffacd0b85a97d-35e0f285ab5mr6799341f8f.28.1717437168661; Mon, 03 Jun 2024 10:52:48 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240603-b4-rbtree-v4-0-308e43d6abfc@google.com> <20240603-b4-rbtree-v4-4-308e43d6abfc@google.com> In-Reply-To: From: Alice Ryhl Date: Mon, 3 Jun 2024 19:52:36 +0200 Message-ID: Subject: Re: [PATCH v4 4/6] rust: rbtree: add mutable iterator To: Boqun Feng Cc: Matt Gilbride , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Greg Kroah-Hartman , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jun 3, 2024 at 7:42=E2=80=AFPM Boqun Feng wr= ote: > > 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 an= d 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. Alice