@@ -146,7 +146,7 @@ pub mod structs {
146146 pub use crate :: repeatn:: RepeatN ;
147147 #[ allow( deprecated) ]
148148 pub use crate :: sources:: { RepeatCall , Unfold , Iterate } ;
149- pub use crate :: take_until :: TakeUntil ;
149+ pub use crate :: take_while_inclusive :: TakeWhileInclusive ;
150150 #[ cfg( feature = "use_alloc" ) ]
151151 pub use crate :: tee:: Tee ;
152152 pub use crate :: tuple_impl:: { TupleBuffer , TupleWindows , CircularTupleWindows , Tuples } ;
@@ -234,7 +234,7 @@ mod rciter_impl;
234234mod repeatn;
235235mod size_hint;
236236mod sources;
237- mod take_until ;
237+ mod take_while_inclusive ;
238238#[ cfg( feature = "use_alloc" ) ]
239239mod tee;
240240mod tuple_impl;
@@ -1392,20 +1392,15 @@ pub trait Itertools : Iterator {
13921392 }
13931393
13941394 /// Returns an iterator adaptor that consumes elements while the given
1395- /// predicate is `false `, *including* the element for which the predicate
1396- /// first returned `true `.
1395+ /// predicate is `true `, *including* the element for which the predicate
1396+ /// first returned `false `.
13971397 ///
13981398 /// The [`.take_while()`][std::iter::Iterator::take_while] adaptor is useful
13991399 /// when you want items satisfying a predicate, but to know when to stop
14001400 /// taking elements, we have to consume that last element that doesn't
14011401 /// satisfy the predicate. This adaptor includes that element where
14021402 /// [`.take_while()`][std::iter::Iterator::take_while] would drop it.
14031403 ///
1404- /// Note that the semantics of this predicate are reversed from
1405- /// [`.take_while()`][std::iter::Iterator::take_while], i.e. this function's
1406- /// predicate yields elements when it evaluates to `false` instead of when
1407- /// it evaluates to `true`.
1408- ///
14091404 /// The [`.take_while_ref()`][crate::Itertools::take_while_ref] adaptor
14101405 /// serves a similar purpose, but this adaptor doesn't require [`Clone`]ing
14111406 /// the underlying elements.
@@ -1414,7 +1409,10 @@ pub trait Itertools : Iterator {
14141409 /// # use itertools::Itertools;
14151410 ///
14161411 /// let items = vec![1, 2, 3, 4, 5];
1417- /// let filtered: Vec<_> = items.into_iter().take_until(|&n| n % 3 == 0).collect();
1412+ /// let filtered: Vec<_> = items
1413+ /// .into_iter()
1414+ /// .take_while_inclusive(|&n| n % 3 != 0)
1415+ /// .collect();
14181416 ///
14191417 /// assert_eq!(filtered, vec![1, 2, 3]);
14201418 /// ```
@@ -1426,7 +1424,7 @@ pub trait Itertools : Iterator {
14261424 /// let take_until_result: Vec<_> = items
14271425 /// .clone()
14281426 /// .into_iter()
1429- /// .take_until (|&n| n % 3 = = 0)
1427+ /// .take_while_inclusive (|&n| n % 3 ! = 0)
14301428 /// .collect();
14311429 /// let take_while_result: Vec<_> = items
14321430 /// .into_iter()
@@ -1448,16 +1446,16 @@ pub trait Itertools : Iterator {
14481446 /// .collect();
14491447 /// let filtered: Vec<_> = non_clonable_items
14501448 /// .into_iter()
1451- /// .take_until (|n| n.0 % 3 = = 0)
1449+ /// .take_while_inclusive (|n| n.0 % 3 ! = 0)
14521450 /// .collect();
14531451 /// let expected: Vec<_> = vec![1, 2, 3].into_iter().map(NoCloneImpl).collect();
14541452 /// assert_eq!(filtered, expected);
1455- fn take_until < F > ( & mut self , accept : F ) -> TakeUntil < Self , F >
1453+ fn take_while_inclusive < F > ( & mut self , accept : F ) -> TakeWhileInclusive < Self , F >
14561454 where
14571455 Self : Sized ,
14581456 F : FnMut ( & Self :: Item ) -> bool ,
14591457 {
1460- take_until :: TakeUntil :: new ( self , accept)
1458+ take_while_inclusive :: TakeWhileInclusive :: new ( self , accept)
14611459 }
14621460
14631461 /// Return an iterator adaptor that filters `Option<A>` iterator elements
0 commit comments