comments explaining why we have and don't have ManuallyDrop

This commit is contained in:
Ralf Jung 2022-06-17 16:23:51 -07:00
parent 901cd3a844
commit 3a1e114120
3 changed files with 6 additions and 0 deletions

View File

@ -175,6 +175,7 @@ pub struct BTreeMap<
> {
root: Option<Root<K, V>>,
length: usize,
/// `ManuallyDrop` to control drop order (needs to be dropped after all the nodes).
pub(super) alloc: ManuallyDrop<A>,
}
@ -384,6 +385,7 @@ pub struct IntoIter<
> {
range: LazyLeafRange<marker::Dying, K, V>,
length: usize,
/// The BTreeMap will outlive this IntoIter so we don't care about drop order for `alloc`.
alloc: A,
}
@ -1800,6 +1802,7 @@ pub struct DrainFilter<
{
pred: F,
inner: DrainFilterInner<'a, K, V>,
/// The BTreeMap will outlive this IntoIter so we don't care about drop order for `alloc`.
alloc: A,
}
/// Most of the implementation of DrainFilter are generic over the type

View File

@ -56,6 +56,7 @@ pub struct VacantEntry<
pub(super) handle: Option<Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge>>,
pub(super) dormant_map: DormantMutRef<'a, BTreeMap<K, V, A>>,
/// The BTreeMap will outlive this IntoIter so we don't care about drop order for `alloc`.
pub(super) alloc: A,
// Be invariant in `K` and `V`
@ -81,6 +82,7 @@ pub struct OccupiedEntry<
pub(super) handle: Handle<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>, marker::KV>,
pub(super) dormant_map: DormantMutRef<'a, BTreeMap<K, V, A>>,
/// The BTreeMap will outlive this IntoIter so we don't care about drop order for `alloc`.
pub(super) alloc: A,
// Be invariant in `K` and `V`

View File

@ -1285,6 +1285,7 @@ pub struct DrainFilter<
{
pred: F,
inner: super::map::DrainFilterInner<'a, T, ()>,
/// The BTreeMap will outlive this IntoIter so we don't care about drop order for `alloc`.
alloc: A,
}