mirror of
https://github.com/Steffo99/patched-porobot.git
synced 2024-12-23 01:54:22 +00:00
Add doctest for champions
This commit is contained in:
parent
43034378fb
commit
f9994c516a
1 changed files with 16 additions and 0 deletions
|
@ -412,6 +412,22 @@ impl Deck {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get an [`Iterator`] of all Champion [`Card`]s in the deck.
|
/// Get an [`Iterator`] of all Champion [`Card`]s in the deck.
|
||||||
|
///
|
||||||
|
/// ```rust
|
||||||
|
/// use patched_porobot::deck;
|
||||||
|
/// use patched_porobot::data::deckcode::deck::Deck;
|
||||||
|
/// use patched_porobot::data::setbundle::card::CardIndex;
|
||||||
|
/// use patched_porobot::data::setbundle::code::CardCode;
|
||||||
|
/// use patched_porobot::data::setbundle::create_cardindex_from_wd;
|
||||||
|
///
|
||||||
|
/// let index: CardIndex = create_cardindex_from_wd();
|
||||||
|
/// let deck: Deck = deck!("CECQCAQCA4AQIAYKAIAQGLRWAQAQECAPEUXAIAQDAEBQOCIBAIAQEMJYAA");
|
||||||
|
/// let champions = deck.champions(&index);
|
||||||
|
///
|
||||||
|
/// let champion_codes: Vec<&str> = champions.map(|c| c.code.full.as_str()).collect();
|
||||||
|
/// const EXPECTED_CODES: [&str; 2] = ["01IO015", "02NX007"];
|
||||||
|
/// assert_eq!(champion_codes, EXPECTED_CODES)
|
||||||
|
/// ```
|
||||||
pub fn champions<'a>(&'a self, cards: &'a CardIndex) -> impl Iterator<Item = &'a Card> {
|
pub fn champions<'a>(&'a self, cards: &'a CardIndex) -> impl Iterator<Item = &'a Card> {
|
||||||
self.contents.keys()
|
self.contents.keys()
|
||||||
.filter_map(|cc| cc.to_card(cards))
|
.filter_map(|cc| cc.to_card(cards))
|
||||||
|
|
Loading…
Reference in a new issue