Skip to content

Commit

Permalink
Merge branch 'main' into am/digits
Browse files Browse the repository at this point in the history
  • Loading branch information
chanced authored Oct 21, 2024
2 parents 7b734cc + 9a15d91 commit 31c7965
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 20 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,14 @@ jobs:
toolchain: ${{ matrix.msrv }}
- name: cargo +${{ matrix.msrv }} check
run: cargo check
toml-fmt:
runs-on: ubuntu-latest
name: toml / fmt
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install taplo
uses: docker://docker.io/tamasfe/taplo:latest
with:
args: fmt --check --diff
40 changes: 20 additions & 20 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
include = ["**/*.toml", "**/Cargo.toml", "Cargo.toml"]
[formatting]
align_comments = true
align_entries = true
allowed_blank_lines = 1
indent_entries = false
reorder_arrays = false
reorder_keys = true
trailing_newline = true
align_comments = true
align_entries = true
allowed_blank_lines = 1
indent_entries = false
reorder_arrays = false
reorder_keys = true
trailing_newline = true

[[rule]]
formatting.align_entries = true
formatting.array_auto_expand = false
formatting.reorder_arrays = true
formatting.reorder_keys = true
include = ["Cargo.toml", "**/Cargo.toml"]
keys = [
"dependencies",
"dev-dependencies",
"build-dependencies",
"workspace.dependencies",
"workspace.dev-dependencies",
"workspace.build-dependencies",
]
formatting.align_entries = true
formatting.array_auto_expand = false
formatting.reorder_arrays = true
formatting.reorder_keys = true
include = ["Cargo.toml", "**/Cargo.toml"]
keys = [
"dependencies",
"dev-dependencies",
"build-dependencies",
"workspace.dependencies",
"workspace.dev-dependencies",
"workspace.build-dependencies",
]
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Adds unsafe associated methods `Pointer::new_unchecked` and `PointerBuf::new_unchecked` for
external zero-cost construction.
- Adds new `ParseIndexError` variant to express the presence non-digit characters in the token.
- Adds `Token::is_next` for checking if a token represents the `-` character.

### Changed

Expand Down
19 changes: 19 additions & 0 deletions src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ impl<'a> Token<'a> {
pub fn to_index(&self) -> Result<Index, ParseIndexError> {
self.try_into()
}

/// Returns if the `Token` is `-`, which stands for the next array index.
///
/// See also [`Self::to_index`].
pub fn is_next(&self) -> bool {
matches!(self.to_index(), Ok(Index::Next))
}
}

macro_rules! impl_from_num {
Expand Down Expand Up @@ -491,4 +498,16 @@ mod tests {
]
});
}

#[test]
fn is_next() {
let token = Token::new("-");
assert!(token.is_next());
let token = Token::new("0");
assert!(!token.is_next());
let token = Token::new("a");
assert!(!token.is_next());
let token = Token::new("");
assert!(!token.is_next());
}
}

0 comments on commit 31c7965

Please sign in to comment.