ramp
                                
                                
                                
                                    ramp copied to clipboard
                            
                            
                            
                        [feature request] Checked primitive type conversion
Add checked conversion for Int to primitive types (u8, u16, u32, ...), similar as in num::bigint trait.
fn to_i64(&self) -> Option<i64> { ... }
                                    
                                    
                                    
                                
This is doable. Do you have a motivating use case for a feature like this?
I think my main motivation back in the days was that I used ramp to implement algorithms which work in a cryptographic context, e.g. do some operations with encrypted values and in the end get the plain (decrypted) result. So my inputs where something like u8, u16 and so on, the encrypted values were ramps big ints and my result in the end should be again u8, u16, ...
Hmm I see. For the sake of brevity, I would hold off on implementing this inside ramp, since it can be done pretty easily with an Int::to_str_radix followed by a u16::from_str_radix or what have you. Is that reasonable?