Skip to content

Commit

Permalink
prepare for release 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wainwrightmark committed Mar 18, 2024
1 parent 2a5e00e commit 6d978c7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ Possible header types:
## v0.7.0 (Unreleased)

- Added `TileByRowIter`. Improved tile iterator methods
- Add `first` and `last` to tile sets
- Add `first`, `pop`, `last`, `pop_last` to tile sets
- More efficient `iter_true_tiles` in tile sets
- More efficient `row_mask` and `col_mask` in tile sets
- Tile set `iter_true_tiles` now implements `FusedIterator` and `DoubleEndedIterator`
- Bumped glam to 0.25.0

## v0.6.0 (2023-11-09)

Expand Down
31 changes: 24 additions & 7 deletions src/tile_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ macro_rules! tile_set {

#[must_use]
#[inline]
pub fn iter_true_tiles(&self) -> impl Iterator<Item = Tile<WIDTH, HEIGHT>> + ExactSizeIterator + core::iter::FusedIterator + DoubleEndedIterator {
pub fn iter_true_tiles(&self) -> impl Iterator<Item = Tile<WIDTH, HEIGHT>> + Clone + core::fmt::Debug + ExactSizeIterator + core::iter::FusedIterator + DoubleEndedIterator {
$true_iter_name::new(self)
}

Expand Down Expand Up @@ -291,7 +291,7 @@ macro_rules! tile_set {
Tile::<WIDTH, HEIGHT>::try_from_inner( self.0.trailing_zeros() as u8)
}

/// Removees the first tile in this set and returns it
/// Removes the first tile in this set and returns it
/// Returns `None` if the set is empty
pub fn pop(&mut self) -> Option<Tile<WIDTH, HEIGHT>>
{
Expand All @@ -303,7 +303,7 @@ macro_rules! tile_set {
Some(Tile::<WIDTH, HEIGHT>::from_inner_unchecked(index as u8))
}

/// Removees the first tile in this set and returns it
/// Removes the first tile in this set and returns it
/// Returns `None` if the set is empty
pub fn pop_last(&mut self) -> Option<Tile<WIDTH, HEIGHT>>
{
Expand Down Expand Up @@ -768,7 +768,7 @@ mod tests {
}

#[test]
fn test_iter_length() {
fn test_iter_length_and_count() {
type Iter = TileSetIter16<2>;

let iter = Iter {
Expand All @@ -777,21 +777,38 @@ mod tests {
top_index: 12,
};

let count = iter.len();
let len = iter.len();

assert_eq!(count, 6)
assert_eq!(len, 6);

let count = iter.count();

assert_eq!(count, 6);
}

#[test]
fn test_true_iter_length() {
fn test_true_iter_length_and_count() {
type Grid = TileSet16<4, 3, 12>;

let mut iter = Grid::ALL.iter_true_tiles();

assert_eq!(12, iter.len());
assert_eq!(12, iter.clone().count());

let _ = iter.next();
assert_eq!(11, iter.len());
assert_eq!(11, iter.count());
}

#[test]
fn test_true_iter_min_max_last() {
type Grid = TileSet16<4, 3, 12>;

let iter = Grid::from_fn(|x|x.inner() % 5 == 0).iter_true_tiles();

assert_eq!(0, iter.clone().min().unwrap().inner());
assert_eq!(10, iter.clone().max().unwrap().inner());
assert_eq!(10, iter.last().unwrap().inner());
}

#[test]
Expand Down

0 comments on commit 6d978c7

Please sign in to comment.