commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
882e780db69c75545607f9d637ea62baaecf9c71 | Lukas Kalbertodt | 2021-12-30T13:19:19 | Add `raw_input` and `into_raw_input` to non-bool `*Lit` types | diff --git a/src/byte/mod.rs b/src/byte/mod.rs
index 5f60e42..273230d 100644
--- a/src/byte/mod.rs
+++ b/src/byte/mod.rs
@@ -37,6 +37,16 @@ impl<B: Buffer> ByteLit<B> {
self.value
}
+ /// Returns the raw input that was passed to `parse`.
+ pub fn raw_input(&self) -> &str {
+ &self.raw
+ ... | 6 | 60 | 0 |
1654e8388ded993402e71e4474665e976cf799d8 | Lukas Kalbertodt | 2021-12-30T13:37:06 | Rewrite `FloatLit` and `IntegerLit` to store full input buffer
All other literals already did that and it's useful to access the raw
input later. I can't imagine the few extra bytes of memory this will
take up being a problem. | diff --git a/src/float/mod.rs b/src/float/mod.rs
index e30a336..51baeba 100644
--- a/src/float/mod.rs
+++ b/src/float/mod.rs
@@ -21,27 +21,27 @@ use crate::{
/// [ref]: https://doc.rust-lang.org/reference/tokens.html#floating-point-literals
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct FloatLit<B: Buffer> ... | 4 | 44 | 44 |
b016540d0e9b8db21b74a84df2a8a52291fde00d | Federico Stra | 2022-09-17T22:16:07 | doc: fix link to reference and clarify bool literals
This fixes #6 by providing good links to the Rust reference and adds the remark that in the Rust syntax `false` and `true` are considered keywords and not actual literals. | diff --git a/src/bool/mod.rs b/src/bool/mod.rs
index 406174c..d7b54a1 100644
--- a/src/bool/mod.rs
+++ b/src/bool/mod.rs
@@ -5,7 +5,11 @@ use crate::{ParseError, err::{perr, ParseErrorKind::*}};
/// A bool literal: `true` or `false`. Also see [the reference][ref].
///
-/// [ref]: https://doc.rust-lang.org/reference... | 1 | 5 | 1 |
47bd6cf84f5560791126f909cf0c9d67f8807763 | Lukas Kalbertodt | 2021-06-04T18:56:24 | Deduplicate code by extracting code for handling raw strings | diff --git a/src/bytestr/mod.rs b/src/bytestr/mod.rs
index 283873d..04047c5 100644
--- a/src/bytestr/mod.rs
+++ b/src/bytestr/mod.rs
@@ -3,7 +3,7 @@ use std::{fmt, ops::Range};
use crate::{
Buffer, ParseError,
err::{perr, ParseErrorKind::*},
- escape::unescape_string,
+ escape::{scan_raw_string, unesca... | 3 | 49 | 60 |
3ad0c4a3a26cddbaf3f00b441fef52d550c1f265 | Lukas Kalbertodt | 2021-06-04T18:49:04 | Deduplicate some code by extracting `unescape_string` | diff --git a/src/bytestr/mod.rs b/src/bytestr/mod.rs
index cbdc192..283873d 100644
--- a/src/bytestr/mod.rs
+++ b/src/bytestr/mod.rs
@@ -3,7 +3,7 @@ use std::{fmt, ops::Range};
use crate::{
Buffer, ParseError,
err::{perr, ParseErrorKind::*},
- escape::{is_string_continue_skipable_whitespace, unescape},
+ ... | 3 | 62 | 97 |
9eaa08b84fe3bd0fe8a4d83439cc54d4c7cebdfb | Lukas Kalbertodt | 2021-05-28T18:31:18 | Fix returned error in `TryFrom<TokenTree>` impls | diff --git a/src/impls.rs b/src/impls.rs
index 3149c37..251f350 100644
--- a/src/impls.rs
+++ b/src/impls.rs
@@ -149,7 +149,7 @@ macro_rules! impl_for_specific_lit {
Ok(lit) => <$ty>::try_from(lit),
Err(actual) => Err(InvalidToken {
actual,
- ... | 2 | 20 | 4 |
966f6cc3a5636dbf18bac8c5d594f04f53a4466b | Lukas Kalbertodt | 2021-05-28T18:17:26 | Remove `TryFrom<proc_macro::Literal>` impl for `BoolLit`
It does not make sense and would always fail. | diff --git a/src/impls.rs b/src/impls.rs
index 24ff7a7..3149c37 100644
--- a/src/impls.rs
+++ b/src/impls.rs
@@ -138,7 +138,12 @@ macro_rules! impl_for_specific_lit {
type Error = InvalidToken;
fn try_from(tt: $($prefix)* TokenTree) -> Result<Self, Self::Error> {
let span = tt... | 3 | 45 | 36 |
f051d742d1bc48d4dfc191fc25a4e11f3b495144 | Lukas Kalbertodt | 2021-05-28T18:01:59 | Fix errors and warnings for `--no-default-features` | diff --git a/src/err.rs b/src/err.rs
index 4323602..dd5b472 100644
--- a/src/err.rs
+++ b/src/err.rs
@@ -19,6 +19,7 @@ impl InvalidToken {
let span = match self.span {
Span::One(s) => s,
+ #[cfg(feature = "proc-macro2")]
Span::Two(s) => s.unwrap(),
};
le... | 4 | 175 | 131 |
fc160bcddffb9a400f957a12ce8a90c976f59fcf | Lukas Kalbertodt | 2021-05-28T17:49:19 | Handle `true` and `false` idents in `TryFrom<TokenTree>` impls | diff --git a/src/impls.rs b/src/impls.rs
index bdc5e9e..75fbd9a 100644
--- a/src/impls.rs
+++ b/src/impls.rs
@@ -192,8 +192,12 @@ macro_rules! impl_tt_to_lit {
let span = tt.span();
let res = match tt {
$($prefix)* TokenTree::Group(_) => Err(TokenKind::Group),
- ... | 3 | 66 | 8 |
65ba7b5c9f9dfecd293e215f5e11b9d78e56994d | Lukas Kalbertodt | 2021-05-28T15:16:51 | Update crate documentation | diff --git a/src/lib.rs b/src/lib.rs
index 9d70d9a..82f008b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -9,19 +9,83 @@
//! built. This crate also offers a bit more flexibility compared to `syn`
//! (only regarding literals, of course).
//!
-//! The main type of this library is [`Literal`]. You can obtain it via
-//!... | 1 | 75 | 16 |
6f3bec6c6a2953511e3bf379ae616c2e40987fca | Lukas Kalbertodt | 2021-05-28T14:49:51 | Adjust example to use new `TryFrom` impls | diff --git a/examples/procmacro/examples/main.rs b/examples/procmacro/examples/main.rs
index 5ed432a..117d816 100644
--- a/examples/procmacro/examples/main.rs
+++ b/examples/procmacro/examples/main.rs
@@ -1,10 +1,12 @@
use procmacro_example::{concat, repeat};
const FOO: &str = concat!(r#"Hello "# 'π¦' "\nHere is a ... | 2 | 14 | 12 |
2291ac49ad300efdd022da72f28a7cb6203aea58 | Lukas Kalbertodt | 2021-05-28T14:49:32 | Add `InvalidToken::to_compile_error[2]` | diff --git a/src/err.rs b/src/err.rs
index c76bb38..4323602 100644
--- a/src/err.rs
+++ b/src/err.rs
@@ -10,6 +10,56 @@ pub struct InvalidToken {
pub(crate) span: Span,
}
+impl InvalidToken {
+ /// Returns a token stream representing `compile_error!("msg");` where
+ /// `"msg"` is the output of `self.to_s... | 1 | 50 | 0 |
0552349a85f58d6787e102d1d75f405b9ffc9382 | Lukas Kalbertodt | 2021-05-28T14:14:55 | Fix doc link | diff --git a/src/err.rs b/src/err.rs
index 9b64330..c76bb38 100644
--- a/src/err.rs
+++ b/src/err.rs
@@ -107,7 +107,7 @@ pub struct ParseError {
impl ParseError {
/// Returns a span of this error, if available. **Note**: the returned span
/// might change in future versions of this library. See [the document... | 1 | 1 | 1 |
322a00efec245cf789c1930e55c085b6daf14a1f | Lukas Kalbertodt | 2021-05-28T14:12:00 | Add `fmt::Display` and `Error` for `InvalidToken` | diff --git a/src/err.rs b/src/err.rs
index ed2d987..9b64330 100644
--- a/src/err.rs
+++ b/src/err.rs
@@ -1,6 +1,8 @@
use std::{fmt, ops::Range};
+/// An error signaling that a different kind of token was expected. Returned by
+/// the various `TryFrom` impls.
#[derive(Debug, Clone, Copy)]
pub struct InvalidToken... | 3 | 51 | 2 |
b76304f9f2173ea71bee3ddb527403cff848eaa3 | Lukas Kalbertodt | 2021-05-28T13:35:24 | Slightly improve helper macro | diff --git a/src/impls.rs b/src/impls.rs
index c563c16..91e0041 100644
--- a/src/impls.rs
+++ b/src/impls.rs
@@ -88,10 +88,12 @@ use crate::{Literal, err::{InvalidToken, TokenKind}};
/// `proc_macro`/`proc_macro2` and `&`/owned.
macro_rules! helper {
($callback:ident, $($input:tt)*) => {
- $callback!([] [... | 1 | 9 | 10 |
557f74d35a1dbd046b1ffed172652672c56c8c93 | Lukas Kalbertodt | 2021-05-28T13:34:13 | Remove code duplication by using helper macro | diff --git a/src/impls.rs b/src/impls.rs
index d9122ec..c563c16 100644
--- a/src/impls.rs
+++ b/src/impls.rs
@@ -84,6 +84,18 @@ use std::convert::TryFrom;
use crate::{Literal, err::{InvalidToken, TokenKind}};
+/// Helper macro to call a `callback` macro four times for all combinations of
+/// `proc_macro`/`proc_ma... | 1 | 49 | 97 |
3e58ed9928c99ee5fbb30a38baeeec585136cd15 | Lukas Kalbertodt | 2021-05-28T13:05:21 | Slightly refactor a test | diff --git a/src/tests.rs b/src/tests.rs
index 1ae24cc..392cff5 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -1,6 +1,6 @@
use std::convert::TryFrom;
-use crate::{ByteStringLit, CharLit, FloatLit, IntegerLit, Literal, StringLit, err::TokenKind};
+use crate::{Literal, StringLit, err::TokenKind};
#[test]
fn empt... | 1 | 24 | 29 |
5629e3777a8fa9ee5b0144c5652b0515e270c4a1 | Lukas Kalbertodt | 2021-05-28T12:38:08 | Add doc test to ensure conversion traits are implemented | diff --git a/src/impls.rs b/src/impls.rs
index 8114001..f25ddab 100644
--- a/src/impls.rs
+++ b/src/impls.rs
@@ -1,3 +1,31 @@
+//! `From` and `TryFrom` impls for various conversions.
+//!
+//! # Tests
+//!
+//! ```no_run
+//! #[cfg(not(feature = "proc-macro2"))]
+//! compile_error!("Run tests with feature `proc-macro2`... | 1 | 28 | 0 |
d45760c2d9aa73e76839d996542c530a1c437cfc | Lukas Kalbertodt | 2021-05-28T11:11:11 | Move some impls into new module | diff --git a/src/err.rs b/src/err.rs
index 917c408..e455b6c 100644
--- a/src/err.rs
+++ b/src/err.rs
@@ -35,13 +35,12 @@ pub struct ParseError {
}
impl ParseError {
- /// Returns a span of this error, if available. **Note**: this is not
- /// stable. See [the documentation of this type][Error] for more
- /... | 3 | 46 | 37 |
1988aefb12ac0d657ec6a7f6d2ab9f12e5d64f83 | Lukas Kalbertodt | 2021-05-28T10:32:40 | Make creating errors easier and result in less code
I would like to deemphasize the error handling code in the parsing
functions. This commit helps with that a bit. Also, this is in
preparation of prefix `Error` and `ErrorKind` with `Parse`. Without
this commit, that change would have made the error creation code even... | diff --git a/src/bool/mod.rs b/src/bool/mod.rs
index b623467..584789f 100644
--- a/src/bool/mod.rs
+++ b/src/bool/mod.rs
@@ -1,6 +1,6 @@
use std::fmt;
-use crate::{Error, ErrorKind};
+use crate::{Error, ErrorKind::*, err::perr};
/// A bool literal: `true` or `false`. Also see [the reference][ref].
@@ -19,7 +19,... | 10 | 101 | 106 |
1caad40cc24a99cab17fb6c8ba733608b8752675 | Lukas Kalbertodt | 2021-05-26T15:22:07 | Move error types into own module | diff --git a/src/err.rs b/src/err.rs
new file mode 100644
index 0000000..c5d6861
--- /dev/null
+++ b/src/err.rs
@@ -0,0 +1,231 @@
+use std::{fmt, ops::Range};
+
+/// Errors during parsing.
+///
+/// This type should be seen primarily for error reporting and not for catching
+/// specific cases. The span and error kind ... | 2 | 234 | 229 |
8093cf45b9a56fda77fdba5119c432787f38ccce | Lukas Kalbertodt | 2021-05-24T19:24:36 | Add Cargo metadata | diff --git a/Cargo.toml b/Cargo.toml
index aa3e500..0df9b13 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,6 +4,25 @@ version = "0.1.0"
authors = ["Lukas Kalbertodt <lukas.kalbertodt@gmail.com>"]
edition = "2018"
+description = """
+Parse and inspect Rust literals (i.e. tokens in the Rust programming language
+repr... | 1 | 19 | 0 |
4a5051541447a2775ee06a84ac15fdae6766bc8a | Lukas Kalbertodt | 2021-05-24T19:04:30 | Add crate level docs | diff --git a/src/lib.rs b/src/lib.rs
index 608f166..988aac0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,3 +1,51 @@
+//! Parsing and inspecting Rust literal tokens.
+//!
+//! This library offers functionality to parse Rust literals, i.e. tokens in the
+//! Rust programming language that represent fixed values. The gr... | 1 | 48 | 0 |
816da51c883dbc939bc493fa21c7417a07593beb | Lukas Kalbertodt | 2021-05-24T18:36:46 | Add `proc-macro[2]` features and add corresponding `From` impls | diff --git a/Cargo.toml b/Cargo.toml
index e2b4322..aa3e500 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,3 +3,10 @@ name = "litrs"
version = "0.1.0"
authors = ["Lukas Kalbertodt <lukas.kalbertodt@gmail.com>"]
edition = "2018"
+
+[features]
+default = ["proc-macro", "proc-macro2"]
+proc-macro = []
+
+[dependencies]... | 4 | 70 | 2 |
4ed61635cdf29337c2c4844764eaec271f3f9e02 | Lukas Kalbertodt | 2021-05-24T18:17:15 | Add and improve documentation | diff --git a/src/byte/mod.rs b/src/byte/mod.rs
index f685c69..7fa5008 100644
--- a/src/byte/mod.rs
+++ b/src/byte/mod.rs
@@ -3,7 +3,11 @@ use core::fmt;
use crate::{Buffer, Error, ErrorKind, escape::unescape};
-
+/// A (single) byte literal, e.g. `b'k'` or `b'!'`.
+///
+/// See [the reference][ref] for more inform... | 6 | 30 | 4 |
5f61768a83ce6435ff8fbf93afce6b9eab9b8fa4 | Lukas Kalbertodt | 2021-05-24T18:01:17 | Implement `fmt::Display` for all literal types | diff --git a/src/bool/mod.rs b/src/bool/mod.rs
index 894d0e3..b623467 100644
--- a/src/bool/mod.rs
+++ b/src/bool/mod.rs
@@ -1,3 +1,5 @@
+use std::fmt;
+
use crate::{Error, ErrorKind};
@@ -38,6 +40,12 @@ impl BoolLit {
}
}
+impl fmt::Display for BoolLit {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> f... | 9 | 102 | 5 |
a9ec0e72706f03293653c67a2c232705b0bbd8c4 | Lukas Kalbertodt | 2021-05-24T17:46:15 | Add `[in]to_owned` methods to all literal types | diff --git a/src/byte/mod.rs b/src/byte/mod.rs
index febe128..a581528 100644
--- a/src/byte/mod.rs
+++ b/src/byte/mod.rs
@@ -58,6 +58,16 @@ impl<B: Buffer> ByteLit<B> {
}
}
+impl ByteLit<&str> {
+ /// Makes a copy of the underlying buffer and returns the owned version of
+ /// `Self`.
+ pub fn to_owned... | 7 | 85 | 0 |
cf8a5ffe74ab51f8a38719be4c68021f9a12ec91 | Lukas Kalbertodt | 2021-05-24T17:22:54 | Add and improve lots of documentation | diff --git a/src/bool/mod.rs b/src/bool/mod.rs
index 5432b92..894d0e3 100644
--- a/src/bool/mod.rs
+++ b/src/bool/mod.rs
@@ -1,6 +1,9 @@
use crate::{Error, ErrorKind};
+/// A bool literal: `true` or `false`. Also see [the reference][ref].
+///
+/// [ref]: https://doc.rust-lang.org/reference/tokens.html#boolean-lit... | 5 | 76 | 32 |
42a7a1e3deab73409475225de283e3caba30cca8 | Lukas Kalbertodt | 2021-05-24T16:53:16 | Add several derives for `Eq` and `Copy`
So regarding `[Partial]Eq`: it makes sense that a user of this library
wants to compare two literals. There is a well defined equality
relation here (i.e. basically the input string). All types currently
implement `PartialEq` in a way the is consistent with that.
Though it's so... | diff --git a/src/bool/mod.rs b/src/bool/mod.rs
index 049b12f..5432b92 100644
--- a/src/bool/mod.rs
+++ b/src/bool/mod.rs
@@ -1,7 +1,7 @@
use crate::{Error, ErrorKind};
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BoolLit {
False,
True,
diff --git a/src... | 8 | 9 | 9 |
e4de7ffc7ed1122d959e5f1a5dd11107748ba4d9 | Lukas Kalbertodt | 2021-05-24T16:38:24 | Add test checking all possible input up to length 4 for panics | diff --git a/src/tests.rs b/src/tests.rs
index c31376b..c02a9c0 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -44,3 +44,53 @@ fn misc() {
assert_err_single!(Literal::parse("B_123"), InvalidLiteral, None);
assert_err_single!(Literal::parse("54321a64"), UnexpectedChar, 5);
}
+
+macro_rules! assert_no_panic {... | 1 | 50 | 0 |
4ee0adb6d6a1da7b9f67862b4376f35f85682821 | Lukas Kalbertodt | 2021-05-24T16:38:02 | Add panic in string parser | diff --git a/src/string/mod.rs b/src/string/mod.rs
index bcc689f..807f943 100644
--- a/src/string/mod.rs
+++ b/src/string/mod.rs
@@ -75,7 +75,7 @@ impl<B: Buffer> StringLit<B> {
break;
}
- if b == b'\r' && input.as_bytes()[start_inner + i + 1] != b'\n' {
+ ... | 1 | 1 | 1 |
428575ca8501d0fbbce738189d873dc8252fb413 | Lukas Kalbertodt | 2021-05-24T16:31:56 | Add some general tests | diff --git a/src/tests.rs b/src/tests.rs
index e37c202..c31376b 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -4,3 +4,43 @@ use crate::Literal;
fn empty() {
assert_err!(Literal, "", Empty, None);
}
+
+#[test]
+fn invalid_literals() {
+ assert_err_single!(Literal::parse("."), InvalidLiteral, None);
+ asse... | 1 | 40 | 0 |
2bfbb64f6f64a0afabba5465efcb0f2039d64b2e | Lukas Kalbertodt | 2021-05-24T16:16:07 | Add a few string tests | diff --git a/src/string/tests.rs b/src/string/tests.rs
index c56c464..941d9e3 100644
--- a/src/string/tests.rs
+++ b/src/string/tests.rs
@@ -155,6 +155,11 @@ fn parse_err() {
assert_err!(StringLit, "\"fo\rx\"", IsolatedCr, 3);
assert_err!(StringLit, "r\"\r\"", IsolatedCr, 2);
assert_err!(StringLit, "r\"f... | 1 | 5 | 0 |
c31af5971db88537242a2690e0447742e8015b01 | Lukas Kalbertodt | 2021-05-24T16:13:41 | Add more byte string tests and fix small bug in byte string parser | diff --git a/src/bytestr/mod.rs b/src/bytestr/mod.rs
index ca65296..969fcb0 100644
--- a/src/bytestr/mod.rs
+++ b/src/bytestr/mod.rs
@@ -114,6 +114,8 @@ impl<B: Buffer> ByteStringLit<B> {
b'\r' if input.as_bytes()[i + 1] != b'\n'
=> return Err(Error::single(i, ErrorKind::Is... | 3 | 67 | 2 |
8e8edb8d797364396dab9c3cb1da97f3a889a0d9 | Lukas Kalbertodt | 2021-05-24T15:13:26 | Add `ByteStringLit::into_value` | diff --git a/src/bytestr/mod.rs b/src/bytestr/mod.rs
index e34cb31..ca65296 100644
--- a/src/bytestr/mod.rs
+++ b/src/bytestr/mod.rs
@@ -35,15 +35,15 @@ impl<B: Buffer> ByteStringLit<B> {
self.value.as_deref().unwrap_or(&self.raw.as_bytes()[self.inner_range()])
}
- // /// Like `value` but returns a p... | 3 | 26 | 11 |
b317cad5bbf54c874208e559a342df9c6c9a0f04 | Lukas Kalbertodt | 2021-05-24T15:05:32 | Add byte strings | diff --git a/src/bytestr/mod.rs b/src/bytestr/mod.rs
new file mode 100644
index 0000000..e34cb31
--- /dev/null
+++ b/src/bytestr/mod.rs
@@ -0,0 +1,147 @@
+use std::ops::Range;
+
+use crate::{Buffer, Error, ErrorKind, escape::unescape};
+
+
+#[derive(Debug, Clone, PartialEq)]
+pub struct ByteStringLit<B: Buffer> {
+ ... | 4 | 277 | 5 |
12178ad883c2a96e23ce67363c8ec68542be642a | Lukas Kalbertodt | 2021-05-24T14:58:17 | Fix small error offset bug in string parsing | diff --git a/src/string/mod.rs b/src/string/mod.rs
index a6ebcaf..bcc689f 100644
--- a/src/string/mod.rs
+++ b/src/string/mod.rs
@@ -84,7 +84,7 @@ impl<B: Buffer> StringLit<B> {
if closing_quote_pos + num_hashes != input.len() - 1 {
return Err(Error::new(
- closing_quo... | 2 | 2 | 1 |
8a02c69dec66e0d7b341ad88b6628872b065640e | Lukas Kalbertodt | 2021-05-24T14:27:45 | Add byte literal test for unicode characters (which is invalid) | diff --git a/src/byte/tests.rs b/src/byte/tests.rs
index 11e6584..5f663ce 100644
--- a/src/byte/tests.rs
+++ b/src/byte/tests.rs
@@ -166,4 +166,8 @@ fn parse_err() {
assert_err!(ByteLit, "b'\n'", UnescapedSpecialWhitespace, 2);
assert_err!(ByteLit, "b'\t'", UnescapedSpecialWhitespace, 2);
assert_err!(Byt... | 2 | 5 | 1 |
7fd4cfaba59a11fd5a1588d62b6a8325dc440be4 | Lukas Kalbertodt | 2021-05-24T14:16:59 | Correctly handle special whitespace (\n, \t, \r) in strings | diff --git a/src/lib.rs b/src/lib.rs
index f96f2bb..05a2cf2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -211,6 +211,10 @@ enum ErrorKind {
/// Invalid start for a byte literal.
InvalidByteLiteralStart,
+
+ /// An literal `\r` character not followed by a `\n` character in a
+ /// (raw) string or byte s... | 3 | 47 | 6 |
a5e1105dc2966147fef59ee4bbe77cbbb9709cc1 | Lukas Kalbertodt | 2021-05-24T13:45:48 | Disallow \n, \r and \t in char and byte literals | diff --git a/src/byte/mod.rs b/src/byte/mod.rs
index 645e220..ee0733f 100644
--- a/src/byte/mod.rs
+++ b/src/byte/mod.rs
@@ -37,8 +37,11 @@ impl<B: Buffer> ByteLit<B> {
let inner = &input[2..input.len() - 1];
let first = inner.as_bytes().get(0).ok_or(Error::spanless(ErrorKind::EmptyByteLiteral))?;
... | 5 | 20 | 2 |
7a287043e43212ecb68b3331cdd538f8c3064097 | Lukas Kalbertodt | 2021-05-24T13:27:07 | Add byte literal | diff --git a/src/byte/mod.rs b/src/byte/mod.rs
new file mode 100644
index 0000000..645e220
--- /dev/null
+++ b/src/byte/mod.rs
@@ -0,0 +1,60 @@
+use crate::{Buffer, Error, ErrorKind, escape::unescape};
+
+
+
+#[derive(Debug, Clone, PartialEq)]
+pub struct ByteLit<B: Buffer> {
+ raw: B,
+ value: u8,
+}
+
+impl<B: ... | 4 | 245 | 2 |
a1af5e2c45b453dc616168cbe38042256c24c263 | Lukas Kalbertodt | 2021-05-24T12:57:09 | Add a couple char literal tests with unicode chars | diff --git a/src/char/tests.rs b/src/char/tests.rs
index c6b2dd4..c4d286e 100644
--- a/src/char/tests.rs
+++ b/src/char/tests.rs
@@ -72,6 +72,13 @@ fn special_chars() {
check!('~');
}
+#[test]
+fn unicode() {
+ check!('ΰ°¨');
+ check!('η¬');
+ check!('π¦');
+}
+
#[test]
fn quote_escapes() {
check!(... | 1 | 7 | 0 |
d57972bd04a14ce43d86e57ccf51afc51afce62c | Lukas Kalbertodt | 2021-05-24T12:54:11 | Add lots of string tests | diff --git a/src/string/tests.rs b/src/string/tests.rs
index 8561116..db2771e 100644
--- a/src/string/tests.rs
+++ b/src/string/tests.rs
@@ -34,6 +34,56 @@ fn simple() {
check!("lit π π af", false, None);
}
+#[test]
+fn simple_escapes() {
+ check!("a\nb", true, None);
+ check!("\nb", true, None);
+ c... | 1 | 117 | 0 |
53cd62570406c4847091633b731257a5e9ce80b2 | Lukas Kalbertodt | 2021-05-24T12:54:06 | Implement non-raw string literals | diff --git a/src/lib.rs b/src/lib.rs
index bc29e31..161dd9f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -193,6 +193,9 @@ enum ErrorKind {
/// Unterminated raw string literal.
UnterminatedRawString,
+ /// String literal without a `"` at the end.
+ UnterminatedString,
+
/// Invalid start for a stri... | 3 | 54 | 2 |
6763390d001bd8d864001d26909a34619f206c02 | Lukas Kalbertodt | 2021-05-23T17:23:30 | Add string literals (WIP)
Parsing only works for raw string literals | diff --git a/src/lib.rs b/src/lib.rs
index 37aebba..bc29e31 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -11,15 +11,17 @@ mod escape;
mod float;
mod integer;
mod parse;
+mod string;
-use std::{fmt, ops::{Deref, Range}};
+use std::{borrow::{Borrow, Cow}, fmt, ops::{Deref, Range}};
pub use self::{
bool::Boo... | 4 | 184 | 3 |
80be54beded6c6ed9e82ce24fc0de5bab8a5db6e | Lukas Kalbertodt | 2021-05-23T15:49:44 | Rename main literal types (`Lit` -> `Literal`, `Foo` -> `FooLit`)
Without the `Lit` suffix, it's a bit confusing for people importing
these types. Especially for the upcoming string literals. I didn't
choose `Literal` as suffix as it might be a bit long then. And "lit"
is already a common abbreviation in Rust world.
... | diff --git a/src/bool/mod.rs b/src/bool/mod.rs
index f1509f4..049b12f 100644
--- a/src/bool/mod.rs
+++ b/src/bool/mod.rs
@@ -2,12 +2,12 @@ use crate::{Error, ErrorKind};
#[derive(Debug, Clone, Copy, PartialEq)]
-pub enum Bool {
+pub enum BoolLit {
False,
True,
}
-impl Bool {
+impl BoolLit {
pub f... | 12 | 267 | 264 |
811d820e0590da267213fe7bc4bc54274315fedb | Lukas Kalbertodt | 2021-05-23T15:02:44 | Implement Unicode escapes | diff --git a/src/char/tests.rs b/src/char/tests.rs
index 1de75fd..2c4b503 100644
--- a/src/char/tests.rs
+++ b/src/char/tests.rs
@@ -99,6 +99,33 @@ fn ascii_escapes() {
check!('\x7f');
}
+#[test]
+fn unicode_escapes() {
+ check!('\u{0}');
+ check!('\u{00}');
+ check!('\u{b}');
+ check!('\u{B}');
+ ... | 3 | 130 | 0 |
da914ff52e468dde862ccd0495241afcba6cf142 | Lukas Kalbertodt | 2021-05-23T13:28:26 | Also check `Lit::parse` in `assert_err` | diff --git a/src/char/tests.rs b/src/char/tests.rs
index d630ddc..1de75fd 100644
--- a/src/char/tests.rs
+++ b/src/char/tests.rs
@@ -101,47 +101,47 @@ fn ascii_escapes() {
#[test]
fn invald_ascii_escapes() {
- assert_err!(Char::parse(r"'\x80'"), NonAsciiXEscape, 1..5);
- assert_err!(Char::parse(r"'\x81'"), No... | 5 | 166 | 159 |
a3078cf7a9cd648959d73600ff8595b0cb2cfb79 | Lukas Kalbertodt | 2021-05-23T13:04:06 | Make float error tests more precise | diff --git a/src/char/mod.rs b/src/char/mod.rs
index c7807a2..ce0f2cf 100644
--- a/src/char/mod.rs
+++ b/src/char/mod.rs
@@ -30,7 +30,7 @@ impl<B: Buffer> Char<B> {
return Err(Error::spanless(ErrorKind::UnterminatedCharLiteral));
}
- let inner = &(*input)[1..input.len() - 1];
+ let... | 3 | 46 | 58 |
bd1a62734abc92604fe4e4341027ffbd42e5899f | Lukas Kalbertodt | 2021-05-23T13:03:46 | Fix two span errors in float parser | diff --git a/src/float/mod.rs b/src/float/mod.rs
index 3b04572..4a9c8c2 100644
--- a/src/float/mod.rs
+++ b/src/float/mod.rs
@@ -125,7 +125,7 @@ impl<B: Buffer> Float<B> {
let end_exponent = end_dec_digits(&rest[exp_number_start..]) + exp_number_start;
if !rest[exp_number_start..end_exponent].... | 1 | 2 | 2 |
049d4b74cf6a14e4c62fc6475ac27cdec64fcaf2 | Lukas Kalbertodt | 2021-05-23T12:47:12 | Remove `Error::kind` method and make `ErrorKind` private
The return value was not stable anyway so there is probably not
point in even exposing it. | diff --git a/src/lib.rs b/src/lib.rs
index cc2e057..ee94a0f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -74,12 +74,6 @@ pub struct Error {
}
impl Error {
- /// Returns the kind of this error. **Note**: this is not stable. See
- /// [the documentation of this type][Error] for more information.
- pub fn kind... | 1 | 1 | 7 |
253396dc2134309d257fab40689124ee6675d7ec | Lukas Kalbertodt | 2021-05-23T12:43:39 | Add some char literal tests and tweak error reporting for char literals | diff --git a/src/char/mod.rs b/src/char/mod.rs
index b46c6e8..c7807a2 100644
--- a/src/char/mod.rs
+++ b/src/char/mod.rs
@@ -23,20 +23,24 @@ impl<B: Buffer> Char<B> {
/// Precondition: first character in input must be `'`.
pub(crate) fn parse_impl(input: B) -> Result<Self, Error> {
- let inner = &(*i... | 3 | 29 | 11 |
50123646c4130c06d365a073cf9dc52c093aa303 | Lukas Kalbertodt | 2021-05-23T12:26:59 | Implement `std::error::Error` for `Error` and add documentation | diff --git a/src/lib.rs b/src/lib.rs
index ad3fd56..cc2e057 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -13,7 +13,7 @@ mod integer;
mod parse;
-use std::ops::{Deref, Range};
+use std::{fmt, ops::{Deref, Range}};
pub use self::{
bool::Bool,
@@ -39,6 +39,34 @@ pub enum Lit<B: Buffer> {
}
+/// Errors dur... | 1 | 80 | 1 |
b281eee134d0833c7a9e4cdf94eb9db2e6006bf3 | Lukas Kalbertodt | 2021-05-23T12:26:40 | Improve some integer error kinds | diff --git a/src/integer/mod.rs b/src/integer/mod.rs
index d9adcce..da1b59b 100644
--- a/src/integer/mod.rs
+++ b/src/integer/mod.rs
@@ -150,7 +150,7 @@ impl<B: Buffer> Integer<B> {
}
if main_part.bytes().filter(|&b| b != b'_').count() == 0 {
- return Err(Error::new(end_prefix..end_prefix... | 3 | 22 | 25 |
96abd1dfcb1ea534b58c995513fdd913825fd451 | Lukas Kalbertodt | 2021-05-23T12:26:17 | Improve some character and escape error kinds | diff --git a/src/char/mod.rs b/src/char/mod.rs
index 0c7dc9f..b46c6e8 100644
--- a/src/char/mod.rs
+++ b/src/char/mod.rs
@@ -24,11 +24,11 @@ impl<B: Buffer> Char<B> {
/// Precondition: first character in input must be `'`.
pub(crate) fn parse_impl(input: B) -> Result<Self, Error> {
let inner = &(*inp... | 4 | 27 | 21 |
b00a01ac23a7fc3f4921e59a0962b8c2b5d7412f | Lukas Kalbertodt | 2021-05-23T11:55:28 | Improve integer parse error reporting and tests | diff --git a/src/integer/mod.rs b/src/integer/mod.rs
index 6d67d1a..d9adcce 100644
--- a/src/integer/mod.rs
+++ b/src/integer/mod.rs
@@ -129,23 +129,31 @@ impl<B: Buffer> Integer<B> {
let without_prefix = &(*input)[end_prefix..];
// Find end of main part.
- let end_main = match base {
- ... | 4 | 70 | 70 |
815929d31e2d1b1a93cdced1f40d2ed4575b32be | Lukas Kalbertodt | 2021-05-23T11:35:54 | Split `Error` type into `Error` and `ErrorKind` & improve most errors | diff --git a/src/bool/mod.rs b/src/bool/mod.rs
index 1414f68..f1509f4 100644
--- a/src/bool/mod.rs
+++ b/src/bool/mod.rs
@@ -1,4 +1,4 @@
-use crate::Error;
+use crate::{Error, ErrorKind};
#[derive(Debug, Clone, Copy, PartialEq)]
@@ -12,7 +12,7 @@ impl Bool {
match s {
"false" => Ok(Self::Fals... | 11 | 193 | 121 |
b6c32fcca5839eaa2298846a3ac06dd6368c05dc | Lukas Kalbertodt | 2021-05-23T10:32:00 | Distinguish extra error in char parsing | diff --git a/src/char/mod.rs b/src/char/mod.rs
index 71ea87d..46d4330 100644
--- a/src/char/mod.rs
+++ b/src/char/mod.rs
@@ -24,13 +24,11 @@ impl<B: Buffer> Char<B> {
/// Precondition: first character in input must be `'`.
pub(crate) fn parse_impl(input: B) -> Result<Self, Error> {
let inner = &(*inp... | 2 | 9 | 7 |
28bb34399f02bfe5c8fa6ca3ad25ff3f69f7892b | Lukas Kalbertodt | 2021-05-23T10:10:24 | Add character literal and unescape function
Unicode escapes are not implemented yet. | diff --git a/src/char/mod.rs b/src/char/mod.rs
new file mode 100644
index 0000000..71ea87d
--- /dev/null
+++ b/src/char/mod.rs
@@ -0,0 +1,52 @@
+use crate::{Buffer, Error, escape::unescape, parse::first_byte_or_empty};
+
+
+
+#[derive(Debug, Clone, PartialEq)]
+pub struct Char<B: Buffer> {
+ raw: B,
+ value: char... | 5 | 274 | 2 |
15b4699e482e790412c9fbf26d3be776ad5ce433 | Lukas Kalbertodt | 2021-05-23T10:09:50 | Extract parts of `Integer::parse` into `hex_digit_value` | diff --git a/src/integer/mod.rs b/src/integer/mod.rs
index d893311..9e0a36e 100644
--- a/src/integer/mod.rs
+++ b/src/integer/mod.rs
@@ -1,4 +1,4 @@
-use crate::{Buffer, Error, parse::first_byte_or_empty};
+use crate::{Buffer, Error, parse::{first_byte_or_empty, hex_digit_value}};
/// An integer literal consisting... | 2 | 15 | 10 |
25d0ab9e192da0c2a331a0c118eecf41d8f4739c | Lukas Kalbertodt | 2021-05-22T19:05:26 | Make lit types generic over the underlying buffer
I can easily imagine use cases for both an owned and a shared literal. | diff --git a/src/float/mod.rs b/src/float/mod.rs
index 6183a66..574bb8c 100644
--- a/src/float/mod.rs
+++ b/src/float/mod.rs
@@ -1,10 +1,10 @@
-use crate::{Error, parse::{end_dec_digits, first_byte_or_empty}};
+use crate::{Buffer, Error, parse::{end_dec_digits, first_byte_or_empty}};
#[derive(Debug, Clone, Par... | 6 | 91 | 52 |
d0bc5afe3b1062ab78598e09e8c7b42c84b67599 | Lukas Kalbertodt | 2021-05-22T16:04:39 | Add more float tests | diff --git a/src/float/tests.rs b/src/float/tests.rs
index 14aa1eb..e46f788 100644
--- a/src/float/tests.rs
+++ b/src/float/tests.rs
@@ -33,6 +33,16 @@ macro_rules! check {
(@stringify_suffix $suffix:ident) => { stringify!($suffix) };
}
+#[track_caller]
+fn assert_err(input: &str) {
+ if Lit::parse(input).is... | 2 | 98 | 9 |
dd736ed6c7ec7a36056a3047a824d397141ed487 | Lukas Kalbertodt | 2021-05-22T15:35:16 | Implement exponent parsing for float literals | diff --git a/src/float/mod.rs b/src/float/mod.rs
index 68722a3..6183a66 100644
--- a/src/float/mod.rs
+++ b/src/float/mod.rs
@@ -38,7 +38,7 @@ pub struct Float<'a> {
type_suffix: Option<FloatType>,
}
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq)]
pub enum FloatType {
F32,
... | 3 | 83 | 20 |
1ca0073203f86e66a9e1b468ee47c302f7058315 | Lukas Kalbertodt | 2021-05-22T13:04:58 | Add some float tests | diff --git a/src/float/mod.rs b/src/float/mod.rs
index 288b629..68722a3 100644
--- a/src/float/mod.rs
+++ b/src/float/mod.rs
@@ -141,3 +141,7 @@ impl<'a> Float<'a> {
})
}
}
+
+
+#[cfg(test)]
+mod tests;
diff --git a/src/float/tests.rs b/src/float/tests.rs
new file mode 100644
index 0000000..440f112
--- /... | 2 | 90 | 0 |
3b2f6e5adec9f6122138e90de920d64e7bd527a1 | Lukas Kalbertodt | 2021-05-22T12:39:14 | Change the internal representation of `Float` and add methods | diff --git a/src/float/mod.rs b/src/float/mod.rs
index 5d4f6c3..288b629 100644
--- a/src/float/mod.rs
+++ b/src/float/mod.rs
@@ -5,16 +5,34 @@ use crate::{Error, parse::{end_dec_digits, first_byte_or_empty}};
#[derive(Debug, Clone, PartialEq)]
pub struct Float<'a> {
- /// Non-empty integer part (before the perio... | 1 | 79 | 27 |
05f124574fa9f2402958f4fc1d9a191b8f8b78e4 | Lukas Kalbertodt | 2021-05-22T11:04:37 | Add extra error kind for invalid integer type suffix | diff --git a/src/integer/mod.rs b/src/integer/mod.rs
index 88faeb0..deea0b4 100644
--- a/src/integer/mod.rs
+++ b/src/integer/mod.rs
@@ -167,9 +167,7 @@ impl<'a> Integer<'a> {
"i64" => Some(IntegerType::I64),
"i128" => Some(IntegerType::I128),
"isize" => Some(IntegerType::Isize),
... | 2 | 8 | 3 |
21347c273db163f1aed19e049dbafd2a2ac6af1b | Lukas Kalbertodt | 2021-05-22T11:02:23 | Add first version of float literal parsing | diff --git a/src/float/mod.rs b/src/float/mod.rs
new file mode 100644
index 0000000..5d4f6c3
--- /dev/null
+++ b/src/float/mod.rs
@@ -0,0 +1,91 @@
+use crate::{Error, parse::{end_dec_digits, first_byte_or_empty}};
+
+
+
+
+#[derive(Debug, Clone, PartialEq)]
+pub struct Float<'a> {
+ /// Non-empty integer part (befor... | 3 | 138 | 7 |
55784e3e896ca3bccbfd1ffc33488bb685ddf99b | Lukas Kalbertodt | 2021-05-20T20:55:50 | Add a couple more integer tests about starting with `_` | diff --git a/src/integer/tests.rs b/src/integer/tests.rs
index 7b64d7b..92c0cda 100644
--- a/src/integer/tests.rs
+++ b/src/integer/tests.rs
@@ -159,6 +159,18 @@ fn parse_hexadecimal() {
check("0xffi128", 0xffi128, Hexadecimal, "ff", Some(Ty::I128));
}
+#[test]
+fn starting_underscore() {
+ check("0b_1", 1, ... | 1 | 14 | 0 |
27ece971d48eb6e0f3943edf36ebd01de8e8c5a7 | Lukas Kalbertodt | 2021-05-20T20:43:34 | Add more integer tests | diff --git a/src/integer/tests.rs b/src/integer/tests.rs
index cd0ce22..7b64d7b 100644
--- a/src/integer/tests.rs
+++ b/src/integer/tests.rs
@@ -87,6 +87,89 @@ fn parse_decimal() {
);
}
+#[test]
+fn parse_binary() {
+ check("0b0", 0b0, Binary, "0", None);
+ check("0b000", 0b000, Binary, "000", None);
+ ... | 1 | 112 | 0 |
25351f3bd79c7d3d2cb8b9f44187e0acf80bd641 | Lukas Kalbertodt | 2021-05-20T20:43:27 | Fix bug for hex digits in `Integer::value`
I made this mistake at least twice before in my life. Hmpf. | diff --git a/src/integer/mod.rs b/src/integer/mod.rs
index 5c1c563..88faeb0 100644
--- a/src/integer/mod.rs
+++ b/src/integer/mod.rs
@@ -89,8 +89,8 @@ impl<'a> Integer<'a> {
// part only contains digits valid for the specified base.
let digit = match digit {
b'0'..=b'9' => dig... | 1 | 2 | 2 |
b42271d86a847439abe61980dde522c7abd5c36f | Lukas Kalbertodt | 2021-05-20T20:12:46 | Improve and add to integer tests | diff --git a/src/integer/tests.rs b/src/integer/tests.rs
index da2363f..cd0ce22 100644
--- a/src/integer/tests.rs
+++ b/src/integer/tests.rs
@@ -47,16 +47,16 @@ fn check<T: FromIntLiteral + PartialEq + Debug + Display>(
#[test]
fn parse_decimal() {
check("0", 0u128, Decimal, "0", None);
- check("1", 1, Decima... | 1 | 79 | 38 |
7cdbd2cced4f0a68080594cbaf8f0ff89a87fec6 | Lukas Kalbertodt | 2021-05-20T19:57:54 | Change `Integer::value()` to be generic over the return type | diff --git a/src/integer/mod.rs b/src/integer/mod.rs
index 1689c0f..5c1c563 100644
--- a/src/integer/mod.rs
+++ b/src/integer/mod.rs
@@ -67,24 +67,26 @@ impl<'a> Integer<'a> {
}
/// Performs the actual string to int conversion to obtain the integer
- /// value. Respects the specified base.
+ /// value... | 2 | 160 | 63 |
ca6f5f476ac47769cb71eecd8f69367a960043d1 | Lukas Kalbertodt | 2021-05-16T21:31:24 | Add `Integer::value` method to actually parse the string to int | diff --git a/src/integer/mod.rs b/src/integer/mod.rs
index d1086f7..1689c0f 100644
--- a/src/integer/mod.rs
+++ b/src/integer/mod.rs
@@ -4,7 +4,19 @@ use crate::{
};
+/// An integer literal consisting of an optional base prefix (`0b`, `0o`, `0x`),
+/// the main part containing digits and optional `_`, and an optio... | 3 | 117 | 11 |
d7224f7b918637cebb72c278738248adfc96464d | Lukas Kalbertodt | 2021-05-16T20:39:59 | Add first version of `Integer` and integer parsing (WIP) | diff --git a/src/integer/mod.rs b/src/integer/mod.rs
new file mode 100644
index 0000000..d1086f7
--- /dev/null
+++ b/src/integer/mod.rs
@@ -0,0 +1,124 @@
+use crate::{
+ Error,
+ parse::first_byte_or_empty,
+};
+
+
+#[derive(Debug, Clone, PartialEq)]
+pub struct Integer<'a> {
+ base: IntegerBase,
+ main_par... | 4 | 218 | 6 |
e7a335721ec31660dbe08805f8bba5e7a7143cd9 | Lukas Kalbertodt | 2021-05-16T20:39:38 | Add `#[track_caller]` to test helper to improve panic location | diff --git a/src/test_util.rs b/src/test_util.rs
index 94c80ab..3655f10 100644
--- a/src/test_util.rs
+++ b/src/test_util.rs
@@ -1,5 +1,6 @@
use crate::*;
+#[track_caller]
pub(crate) fn assert_parse_ok_eq<T: PartialEq + std::fmt::Debug>(
input: &str,
result: Result<T, Error>, | 1 | 1 | 0 |
cb8fd257cd6f664dc4f8887c2c1587ec45c712bf | Lukas Kalbertodt | 2021-05-16T18:48:01 | Add `Bool::{value, as_str}` | diff --git a/src/bool/mod.rs b/src/bool/mod.rs
index 9b5f826..1414f68 100644
--- a/src/bool/mod.rs
+++ b/src/bool/mod.rs
@@ -15,6 +15,20 @@ impl Bool {
_ => Err(Error::InvalidLiteral)
}
}
+
+ pub fn value(self) -> bool {
+ match self {
+ Self::False => false,
+ ... | 2 | 28 | 2 |
2a802005de958bbe72e6562a5369a0d441f1e0d9 | Lukas Kalbertodt | 2021-05-16T18:45:09 | Restructure project | diff --git a/src/bool/mod.rs b/src/bool/mod.rs
new file mode 100644
index 0000000..9b5f826
--- /dev/null
+++ b/src/bool/mod.rs
@@ -0,0 +1,22 @@
+use crate::Error;
+
+
+#[derive(Debug, Clone, Copy, PartialEq)]
+pub enum Bool {
+ False,
+ True,
+}
+
+impl Bool {
+ pub fn parse(s: &str) -> Result<Self, Error> {
+... | 7 | 105 | 55 |
e45a014f828089ac03003dfca4a87780e4343730 | cetra3 | 2024-11-28T12:33:52 | Make range structs public (#10) | diff --git a/src/lib.rs b/src/lib.rs
index eb43f2b..76538b9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -211,7 +211,7 @@ fn strict_parse_u64(s: &str) -> Option<u64> {
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct ParsedRanges {
- ranges: Vec<SyntacticallyCorrectRange>,
+ pub ranges: Vec<SyntacticallyCorre... | 1 | 6 | 6 |
9b72a7a670542a9165db0c0d49e199daaeb31e4b | MarcusGrass | 2024-05-03T11:51:31 | Add some fuzzing comments, add tests for validating a zero byte file length | diff --git a/fuzz/fuzz_targets/random_string_input.rs b/fuzz/fuzz_targets/random_string_input.rs
index c4c1680..7a7194e 100644
--- a/fuzz/fuzz_targets/random_string_input.rs
+++ b/fuzz/fuzz_targets/random_string_input.rs
@@ -4,11 +4,15 @@ use libfuzzer_sys::fuzz_target;
use regex::Regex;
lazy_static::lazy_static! {... | 2 | 20 | 0 |
f50d8ced28afc05243aa9fdb3fff704590fd5995 | MarcusGrass | 2024-05-03T11:39:29 | Cleanup test lints, allow uninlined fmt args | diff --git a/src/lib.rs b/src/lib.rs
index 8d8e0db..e3385e3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,4 +1,5 @@
#![warn(clippy::pedantic)]
+#![allow(clippy::uninlined_format_args)]
use core::fmt::{Debug, Display, Formatter};
use core::ops::RangeInclusive;
@@ -373,7 +374,7 @@ mod tests {
use core::ops::Ra... | 1 | 20 | 20 |
6278893a09e7868cd4d3f9f610a8446b0d6dc858 | Chris Holcombe | 2024-05-03T11:32:31 | Check subtractions for overflow (#8) | diff --git a/src/lib.rs b/src/lib.rs
index 24eccc4..8d8e0db 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -234,12 +234,12 @@ impl ParsedRanges {
if i > file_size_bytes {
return Err(RangeUnsatisfiableError::FileSuffixOutOfBounds);
}
- fi... | 1 | 13 | 3 |
fe31dfdc199fae7ba507faf2efbe99087df5526d | MarcusGrass | 2023-07-21T07:49:31 | Fixup doctest | diff --git a/src/lib.rs b/src/lib.rs
index ab6b9fd..88ecfee 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -85,16 +85,16 @@ mod macros;
/// syntactically correct ranges actually makes sense in context
///
/// The range `bytes=0-20` on a file with 15 bytes will be accepted in the first pass as the content_size is unknow... | 1 | 4 | 4 |
36a082abb17ab82ff92fb5240ca0c08e115a4c12 | Josh Faust | 2023-07-20T17:34:17 | Support range headers with an end range past EOF
This is specified in section 14.1.2 of the httpwg rfc9110, and
section 14.35.1 of the ietf rfc2616 linked in this repo:
"A client can limit the number of bytes requested without knowing the
size of the selected representation. If the last-pos value is absent, or if
the... | diff --git a/src/lib.rs b/src/lib.rs
index c5999d2..ab6b9fd 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -277,16 +277,12 @@ impl ParsedRanges {
}
};
let end = match parsed.end {
- EndPosition::Index(i) => i,
+ EndPosition::Index(i) => std::cmp::min... | 1 | 9 | 11 |
f5cc08c4acea606e7eb0b1b920213fbe1cce8a5c | gramar | 2021-11-25T09:29:39 | Fix rejecting a single reversed range | diff --git a/Cargo.toml b/Cargo.toml
index 2c8b691..be49aea 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "http-range-header"
-version = "0.2.1"
+version = "0.2.2"
edition = "2018"
license = "MIT"
readme = "./README.md"
diff --git a/src/lib.rs b/src/lib.rs
index 3677246..3f55d3f 100644
... | 2 | 16 | 4 |
15179a926a1fd2ee81256deb10bf25d8dd9b1774 | gramar | 2021-11-25T09:10:45 | Update Cargo.toml | diff --git a/Cargo.toml b/Cargo.toml
index 2d1b184..2c8b691 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "http-range-header"
-version = "0.2.0"
+version = "0.2.1"
edition = "2018"
license = "MIT"
readme = "./README.md"
@@ -9,7 +9,7 @@ repository = "https://github.com/MarcusGrass/parse-... | 1 | 2 | 2 |
55c4e1a1abd0e3c131b2ee325b87857e7a567a6d | gramar | 2021-11-25T09:09:21 | Update Cargo.toml | diff --git a/Cargo.toml b/Cargo.toml
index ed1ccfd..2d1b184 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "http-range-header"
-version = "0.1.0"
+version = "0.2.0"
edition = "2018"
license = "MIT"
readme = "./README.md"
@@ -9,7 +9,7 @@ repository = "https://github.com/MarcusGrass/parse-... | 1 | 2 | 2 |
77f81f35fb10e9deada221d2cee5770098f1c961 | gramar | 2021-11-24T17:52:42 | Do some benchmarking and optimizations | diff --git a/Cargo.toml b/Cargo.toml
index 557d65c..ed1ccfd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,6 +17,11 @@ with_error_cause = []
[dependencies]
[dev-dependencies]
+criterion = "0.3.5"
quickcheck = "1.0.3"
quickcheck_macros = "1.0.0"
regex = "1.5.4"
+
+[[bench]]
+name = "benchmark"
+harness = false
d... | 4 | 60 | 45 |
4ec4ceb246ef5a20b0d9a2a95c8636d10883bf7a | gramar | 2021-11-24T16:42:43 | Update crate name and clean up | diff --git a/Cargo.toml b/Cargo.toml
index 9b1e7e4..557d65c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "parse_range_headers"
+name = "http-range-header"
version = "0.1.0"
edition = "2018"
license = "MIT"
diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml
index 558f58a..3ea3750 100644
---... | 5 | 46 | 45 |
f41a8f91e63d61142ca824024cfc1ba22129b41d | gramar | 2021-11-24T15:52:31 | Move macros and remove some visibility | diff --git a/Cargo.toml b/Cargo.toml
index 0e29f69..9b1e7e4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,7 +9,7 @@ repository = "https://github.com/MarcusGrass/parse-range-headers"
homepage = "https://github.com/MarcusGrass/parse-range-headers"
categories = ["parser-implementations", "network-programming", "web-pro... | 3 | 31 | 43 |
c2bb9ed086cef644adf313d8d4cf8164a1052d13 | gramar | 2021-11-24T15:39:54 | Inline parse and enforce bytes-ranges | diff --git a/Cargo.toml b/Cargo.toml
index 26063ad..0e29f69 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,12 +5,11 @@ edition = "2018"
license = "MIT"
readme = "./README.md"
description = "No-dep range header parser"
-repository = "https://github.com/MarcusGrass/range_header"
-homepage = "https://github.com/MarcusG... | 2 | 42 | 60 |
9792493d7e025c909205926ab5943a9e3e984d41 | A248 | 2026-01-22T20:06:04 | Use core::ptr (no-std compat) | diff --git a/src/arc.rs b/src/arc.rs
index e1a4e47..601dcab 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -12,10 +12,9 @@ use core::marker::PhantomData;
use core::mem::{ManuallyDrop, MaybeUninit};
use core::ops::Deref;
use core::panic::{RefUnwindSafe, UnwindSafe};
-use core::ptr::{self, NonNull};
+use core::ptr::{addr... | 1 | 1 | 2 |
1c1b26f911586861bf6faacf1be3fb6eb4d3e210 | A248 | 2026-01-21T19:35:21 | Switch to addr_of_mut! for 1.82 compat (drop this commit if unwanted) | diff --git a/src/arc.rs b/src/arc.rs
index c876157..e1a4e47 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -15,7 +15,7 @@ use core::panic::{RefUnwindSafe, UnwindSafe};
use core::ptr::{self, NonNull};
use core::sync::atomic;
use core::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release};
-
+use std::ptr::addr_of_... | 2 | 7 | 7 |
0f5dc1428eb04d25d9ebfd7547d5cfdc04749f6c | A248 | 2026-01-21T19:31:45 | Run cargo fmt | diff --git a/src/arc.rs b/src/arc.rs
index 56c91c1..c876157 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -384,7 +384,7 @@ impl<T: ?Sized> Arc<T> {
.pad_to_align();
// ArcInner never has a zero size
- let ptr = alloc::alloc::alloc(full_layout);
+ let ptr = alloc::all... | 2 | 2 | 2 |
96eb99930d878bd7c3aba1aa115cccf51958ca1a | A248 | 2026-01-14T11:36:00 | Update slice DST ops, use &raw mut, and improve documentation | diff --git a/src/arc.rs b/src/arc.rs
index d95b247..56c91c1 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -356,6 +356,10 @@ impl<T: ?Sized> Arc<T> {
/// The function `mem_to_arcinner` is called with the data pointer
/// and must return back a (potentially fat)-pointer for the `ArcInner<T>`.
///
+ /// Th... | 2 | 57 | 65 |
7fa2e4d72b2aca39e08b56e1b2f17dbf440542b7 | Jonas Platte | 2025-12-31T17:48:51 | Implement From<&str>, From<String> for OffsetArc<str> | diff --git a/src/header.rs b/src/header.rs
index c606fb2..a7f7ac8 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -8,6 +8,8 @@ use core::marker::PhantomData;
use core::mem::{self, ManuallyDrop};
use core::ptr::{self, addr_of_mut};
+use crate::OffsetArc;
+
use super::{Arc, ArcInner};
/// Structure to allow Arc... | 1 | 14 | 0 |
3b152d48f2586b2115a038af38e6fc6686a04529 | Jonas Platte | 2025-12-31T17:52:55 | Implement Hash for OffsetArc | diff --git a/src/offset_arc.rs b/src/offset_arc.rs
index 27f8b9c..0dde04a 100644
--- a/src/offset_arc.rs
+++ b/src/offset_arc.rs
@@ -1,4 +1,5 @@
use core::fmt;
+use core::hash::Hash;
use core::marker::PhantomData;
use core::mem::ManuallyDrop;
use core::ops::Deref;
@@ -96,6 +97,12 @@ impl<T: ?Sized + Ord> Ord for Of... | 1 | 7 | 0 |
0f7da89b74038bef057e2ece3fe50438a3dacfec | Jonas Platte | 2025-12-31T17:42:52 | Implement PartialOrd, Ord for OffsetArc | diff --git a/src/offset_arc.rs b/src/offset_arc.rs
index 5164d5b..27f8b9c 100644
--- a/src/offset_arc.rs
+++ b/src/offset_arc.rs
@@ -84,6 +84,18 @@ impl<T: ?Sized + PartialEq> PartialEq for OffsetArc<T> {
impl<T: ?Sized + Eq> Eq for OffsetArc<T> {}
+impl<T: ?Sized + PartialOrd> PartialOrd for OffsetArc<T> {
+ f... | 1 | 12 | 0 |
4ce4c9faa5171ba0c04d45e3b632acbe93219b85 | Jonas Platte | 2025-12-31T17:39:29 | Allow non-Sized types in OffsetArc | diff --git a/src/arc.rs b/src/arc.rs
index e0f0960..d95b247 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -108,27 +108,6 @@ impl<T> Arc<T> {
f(&transient)
}
- /// Converts an `Arc` into a `OffsetArc`. This consumes the `Arc`, so the refcount
- /// is not modified.
- #[inline]
- pub fn into_raw... | 2 | 50 | 46 |
3fc193a619175a461faf6d6cb976e304418420f0 | Sumit Modak | 2025-11-08T17:54:46 | missing colon | diff --git a/src/lib.rs b/src/lib.rs
index 901553a..c2581c1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -16,7 +16,7 @@
//! * `triomphe::ArcBorrow` is functionally similar to `&triomphe::Arc<T>`, however in memory it's simply `&T`. This makes it more flexible for FFI; the source of the borrow need not be an `Arc` pinne... | 1 | 1 | 1 |
622a0f15bf2443457b1efd9fc77199027e87c687 | Manish Goregaokar | 2025-10-06T02:54:48 | Bump to 0.1.15, update edition to 2024 | diff --git a/Cargo.toml b/Cargo.toml
index f742cb5..ed10673 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "triomphe"
-version = "0.1.14"
+version = "0.1.15"
authors = ["Manish Goregaokar <manishsmail@gmail.com>", "The Servo Project Developers"]
license = "MIT OR Apache-2.0"
repository =... | 1 | 2 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.