emacs-module-rs icon indicating copy to clipboard operation
emacs-module-rs copied to clipboard

Permissive `FromLisp` for numeric types?

Open fosskers opened this issue 3 years ago • 1 comments

Thanks again for the cool library. General question: should into_rust::<f64>() succeed for non-float literals like 1? Currently it fails, but I'm not sure what users should expect in general here.

Thoughts? Thanks you kindly.

fosskers avatar Jun 20 '22 22:06 fosskers

A current workaround I'm using:

            v.into_rust::<f64>()
                .or_else(|_| v.into_rust::<i64>().map(|n| n as f64))
                .ok()

fosskers avatar Jun 20 '22 22:06 fosskers