1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
use super::error_pos::ErrorPos;
use std::result;

pub trait WithPos {
    /// Add additional position information, if it's not already present.
    fn with_pos<E: Into<ErrorPos>>(self, pos: E) -> Self;
}

impl<T, E> WithPos for result::Result<T, E>
where
    E: WithPos,
{
    fn with_pos<P: Into<ErrorPos>>(self, pos: P) -> Self {
        self.map_err(|e| e.with_pos(pos))
    }
}