5

Github Tracking Issue for {HashMap,BTreeMap}::into_{keys,values} · Issue #75294...

 3 years ago
source link: https://github.com/rust-lang/rust/issues/75294
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

canova commented on Aug 8, 2020

edited by m-ou-se

Feature gate: #![feature(map_into_keys_values)]

This is a tracking issue for {HashMap,BTreeMap}::into_{keys,values}.

Public API

// alloc::collections::btree_map

impl<K, V> BTreeMap<K, V> {
    pub fn into_keys(self) -> IntoKeys<K, V>;
    pub fn into_values(self) -> IntoValues<K, V>;
}

pub struct IntoKeys<K, V>;
pub struct IntoValues<K, V>;

impl<K, V> Iterator for IntoKeys<K, V> { type Item = K; }
impl<K, V> DoubleEndedIterator for IntoKeys<K, V> {}
impl<K, V> ExactSizeIterator for IntoKeys<K, V> {}
impl<K, V> FusedIterator for IntoKeys<K, V> {}
impl<K: Debug, V> Debug for IntoKeys<K, V> {}

impl<K, V> Iterator for IntoValues<K, V> { type Item = V; }
impl<K, V> DoubleEndedIterator for IntoValues<K, V> {}
impl<K, V> ExactSizeIterator for IntoValues<K, V> {}
impl<K, V> FusedIterator for IntoValues<K, V> {}
impl<K, V: Debug> Debug for IntoValues<K, V> {}

// alloc::collections::hash_map

impl<K: Eq + Hash, V, S: BuildHasher> HashMap<K, V, S> {
    pub fn into_keys(self) -> IntoKeys<K, V>;
    pub fn into_values(self) -> IntoValues<K, V>;
}

pub struct IntoKeys<K, V>;
pub struct IntoValues<K, V>;

impl<K, V> Iterator for IntoKeys<K, V> { type Item = K; }
impl<K, V> ExactSizeIterator for IntoKeys<K, V> {}
impl<K, V> FusedIterator for IntoKeys<K, V> {}
impl<K: Debug, V> Debug for IntoKeys<K, V> {}

impl<K, V> Iterator for IntoValues<K, V> { type Item = V; }
impl<K, V> ExactSizeIterator for IntoValues<K, V> {}
impl<K, V> FusedIterator for IntoValues<K, V> {}
impl<K, V: Debug> Debug for IntoValues<K, V> {}

Steps / History

  • Requested in #55214.
  • Implementation: #75163
  • Final commenting period (FCP)
  • Stabilization PR: #84328

Unresolved Questions

  • None yet.

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK