alamb commented on PR #7807:
URL: https://github.com/apache/arrow-rs/pull/7807#issuecomment-3025006167

   > @alamb -- what are your thoughts here? I'm not convinced a get that can 
panic and yet still returns Option is ever better than a try_get that cannot 
panic and returns Result? Either way you have to handle the "error" case, so 
there's no usability or readability improvement to offset the panic risk?
   
   I personally think Option is slightly easier to reason about (and is more 
performance as it doesn't allocate a String for the error). 
   
   I also think there is a subtle difference between the two APIs:
   1. A `get()` that returns None (the key wasn't found) is a condition that 
you expect will happen with valid input and normal operation
   2. A `try_get()` that returns an Err is something you expect **won't 
happen** in normal operation, and thus having all call sites have to deal with 
the "error that should not happen" case is wonky
   
   I suggest personally we change `try_get()` to return `Result<Option<..>>` to 
reflect that the `None` is expected in normal operation while the error is not


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to