Skip to content

Commit ab1a2a9

Browse files
authored
Turn parse::ShortInput into a newtype of (). (#6)
This will make it possible to enrich the type later without needing a breaking change.
1 parent b28085f commit ab1a2a9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/parse.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl<Ref: AsRef<[u8]>> Parser<Ref> {
131131
/// returned.
132132
pub fn seek(&mut self, pos: usize) -> Result<(), ShortInput> {
133133
if pos > self.len {
134-
Err(ShortInput)
134+
Err(ShortInput(()))
135135
} else {
136136
self.pos = pos;
137137
Ok(())
@@ -143,7 +143,7 @@ impl<Ref: AsRef<[u8]>> Parser<Ref> {
143143
/// If this would take the parser beyond its end, an error is returned.
144144
pub fn advance(&mut self, len: usize) -> Result<(), ShortInput> {
145145
if len > self.remaining() {
146-
Err(ShortInput)
146+
Err(ShortInput(()))
147147
} else {
148148
self.pos += len;
149149
Ok(())
@@ -160,7 +160,7 @@ impl<Ref: AsRef<[u8]>> Parser<Ref> {
160160
/// If there aren’t, returns an error.
161161
pub fn check_len(&self, len: usize) -> Result<(), ShortInput> {
162162
if self.remaining() < len {
163-
Err(ShortInput)
163+
Err(ShortInput(()))
164164
} else {
165165
Ok(())
166166
}
@@ -181,7 +181,7 @@ impl<Ref: AsRef<[u8]>> Parser<Ref> {
181181
{
182182
let end = self.pos + len;
183183
if end > self.len {
184-
return Err(ShortInput);
184+
return Err(ShortInput(()));
185185
}
186186
let res = self.octets.range(self.pos, end);
187187
self.pos = end;
@@ -275,8 +275,8 @@ impl<Ref: AsRef<[u8]>> Parser<Ref> {
275275
//--------- ShortInput -------------------------------------------------------
276276

277277
/// An attempt was made to go beyond the end of the parser.
278-
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
279-
pub struct ShortInput;
278+
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
279+
pub struct ShortInput(());
280280

281281
//--- Display and Error
282282

0 commit comments

Comments
 (0)