Last active
August 29, 2015 14:08
-
-
Save jbrestan/80cc26a10852339974a1 to your computer and use it in GitHub Desktop.
Generic F# wrapper over BCL "static bool TryParse(string, out T)" pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let inline tryParse input = | |
let mutable result = Unchecked.defaultof< ^a> | |
if (^a: (static member TryParse : string -> ^a byref -> bool) (input, &result)) | |
then Some(result) else None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Check out https://github.com/gmpl/FsControl/blob/master/FsControl.Core/Converter.fs#L70-L78