rem-command-line 0.1.0

CLI interface for the REM toolchain. Built to be implemented into the VSCode extension for REM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
impl ObjectId {
    pub fn new_foo(buffer: &[u8]) -> Result<ObjectId, Error> {
        match buffer.len() {
            40 => Self::bar(buffer),
            len => Err(Error::InvalidHexEncodingLength(len)),
        }
    }
    fn bar(buffer: &[u8]) -> RetBar<Result<ObjectId, Error>, Result<ObjectId, Error>> {
        Ok(ObjectId::Sha1(<[u8; 20]>::from_hex(buffer).map_err(
            |err| match err {
                hex::FromHexError::InvalidHexCharacter { c, index } => Error::Invalid { c, index },
                hex::FromHexError::OddLength | hex::FromHexError::InvalidStringLength => {
                    unreachable!("BUG: This is already checked")
                }
            },
        )?))
    }
}