Skip to content

Commit

Permalink
feat(zero-sized): add EmptyStr, LeftArrow, RightArrow
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsonin committed May 21, 2024
1 parent ef0c53b commit d7cf33d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- next-header -->

## [2.2.0] - 2024-05-21
### Added
- `auxiliary::EmptyStr`
- `auxiliary::LeftArrow`
- `auxiliary::RightArrow`

## [2.1.0] - 2024-05-15
### Added
- `PrintableWrapper: Clone`
Expand All @@ -24,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `PrintableTuple`

<!-- next-url -->
[2.2.0]: https://github.com/andrewsonin/printable/releases/tag/v2.2.0
[2.1.0]: https://github.com/andrewsonin/printable/releases/tag/v2.1.0
[2.0.0]: https://github.com/andrewsonin/printable/releases/tag/v2.0.0
[1.0.0]: https://github.com/andrewsonin/printable/releases/tag/v1.0.0
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "printable"
version = "2.1.0"
version = "2.2.0"
authors = ["Andrew Sonin <sonin.cel@yandex.ru>"]
categories = ["value-formatting"]
description = "Provides `std::fmt::Display` wrapper for iterators and tuples."
Expand Down
36 changes: 36 additions & 0 deletions src/auxiliary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,39 @@ impl Display for RightSquareBracket {
f.write_char(']')
}
}

/// Zero-sized type, which is displayed as empty string.
#[derive(Debug, Clone, Copy)]
#[repr(transparent)]
pub struct EmptyStr;

impl Display for EmptyStr {
#[inline]
fn fmt(&self, _f: &mut Formatter<'_>) -> std::fmt::Result {
Ok(())
}
}

/// Zero-sized type, which is displayed as `<-`.
#[derive(Debug, Clone, Copy)]
#[repr(transparent)]
pub struct LeftArrow;

impl Display for LeftArrow {
#[inline]
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str("<-")
}
}

/// Zero-sized type, which is displayed as `->`.
#[derive(Debug, Clone, Copy)]
#[repr(transparent)]
pub struct RightArrow;

impl Display for RightArrow {
#[inline]
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str("->")
}
}

0 comments on commit d7cf33d

Please sign in to comment.