m4b
m4b
So to be clear the pattern I don't like is this: ```rust if let Hint::Unknown(magic) = peek { println!("unknown magic: {:#x}", magic) } else { let bytes = { let...
```rust let object = Object::peek_and_parse(fd, &mut bytes)??; ``` It looks we're angrily confused about the goblin library and this function call :rofl:
What if you pass an invalid magic? It will have either error with bad magic (same problem I mentioned above) or return variant of Unknown, or still have signature like...
Right, but what would the internal logic of `parse(magic: usize, bytes: &[u8])` look like? It has to still check the magic is valid - either it will return Option, Result...
Oh, I see what you're saying, I thought the peek was a usize: ```rust fn parse(hint: Hint, bytes: &[u8]) -> Result { match hint { Elf => // parse elf,...
Yea I like that idea; it makes using goblin from raw bytes slightly more complicated though. Using your proposal I think I like this api: ```rust fn peek(fd: &mut File)...
@willglynn yea that's a good point. However @sunfishcode 's option proposal I think somewhat sidesteps this issue. It forces the user to pass a peek. They either got the peek...
@willglynn yea i probably overstated things when I said it's _guaranteed_ :laughing: As a bonus I think I can also have my angry double `??` version using the option peek...
I think my last suggestion is actually a good idea, or dan's; I think pre-release 1.0 one of them should be chosen.
This will be a breaking change but i think its important to match elf resultless iterators