Spell out pos -> position

This commit is contained in:
David Tolnay 2018-03-28 14:51:42 +02:00
parent 2dd0b6edce
commit be29e749d3
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 14 additions and 14 deletions

View File

@ -168,15 +168,15 @@ impl<'de, R: Read<'de>> Deserializer<R> {
/// Error caused by a byte from next_char(). /// Error caused by a byte from next_char().
#[cold] #[cold]
fn error(&self, reason: ErrorCode) -> Error { fn error(&self, reason: ErrorCode) -> Error {
let pos = self.read.position(); let position = self.read.position();
Error::syntax(reason, pos.line, pos.column) Error::syntax(reason, position.line, position.column)
} }
/// Error caused by a byte from peek(). /// Error caused by a byte from peek().
#[cold] #[cold]
fn peek_error(&self, reason: ErrorCode) -> Error { fn peek_error(&self, reason: ErrorCode) -> Error {
let pos = self.read.peek_position(); let position = self.read.peek_position();
Error::syntax(reason, pos.line, pos.column) Error::syntax(reason, position.line, position.column)
} }
/// Returns the first non-whitespace byte without consuming it, or `None` if /// Returns the first non-whitespace byte without consuming it, or `None` if
@ -1936,11 +1936,11 @@ where
Some(b' ') | Some(b'\n') | Some(b'\t') | Some(b'\r') | Some(b'"') | Some(b'[') Some(b' ') | Some(b'\n') | Some(b'\t') | Some(b'\r') | Some(b'"') | Some(b'[')
| Some(b']') | Some(b'{') | Some(b'}') | Some(b',') | Some(b':') | None => Ok(()), | Some(b']') | Some(b'{') | Some(b'}') | Some(b',') | Some(b':') | None => Ok(()),
Some(_) => { Some(_) => {
let pos = self.de.read.peek_position(); let position = self.de.read.peek_position();
Err(Error::syntax( Err(Error::syntax(
ErrorCode::TrailingCharacters, ErrorCode::TrailingCharacters,
pos.line, position.line,
pos.column, position.column,
)) ))
} }
} }

View File

@ -292,19 +292,19 @@ impl<'a> SliceRead<'a> {
} }
fn position_of_index(&self, i: usize) -> Position { fn position_of_index(&self, i: usize) -> Position {
let mut pos = Position { line: 1, column: 0 }; let mut position = Position { line: 1, column: 0 };
for ch in &self.slice[..i] { for ch in &self.slice[..i] {
match *ch { match *ch {
b'\n' => { b'\n' => {
pos.line += 1; position.line += 1;
pos.column = 0; position.column = 0;
} }
_ => { _ => {
pos.column += 1; position.column += 1;
} }
} }
} }
pos position
} }
/// The big optimization here over IoRead is that if the string contains no /// The big optimization here over IoRead is that if the string contains no
@ -544,8 +544,8 @@ fn next_or_eof<'de, R: ?Sized + Read<'de>>(read: &mut R) -> Result<u8> {
} }
fn error<'de, R: ?Sized + Read<'de>, T>(read: &R, reason: ErrorCode) -> Result<T> { fn error<'de, R: ?Sized + Read<'de>, T>(read: &R, reason: ErrorCode) -> Result<T> {
let pos = read.position(); let position = read.position();
Err(Error::syntax(reason, pos.line, pos.column)) Err(Error::syntax(reason, position.line, position.column))
} }
fn as_str<'de, 's, R: Read<'de>>(read: &R, slice: &'s [u8]) -> Result<&'s str> { fn as_str<'de, 's, R: Read<'de>>(read: &R, slice: &'s [u8]) -> Result<&'s str> {