You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This could be useful at times. The concrete use case I have is a string that needs to be converted to Value. The string could be either numerical in which case it should be Value::Number or just a text, in which case it will be Value::String.
So I am using next code:
// text here is &strifletOk(number) = text.parse::<Number>(){Value::Number(number)}else{Value::from(text)}
Writing Value::from(number) feels cleaner
The text was updated successfully, but these errors were encountered:
imp
added a commit
to imp/json
that referenced
this issue
Dec 28, 2020
This could be useful at times. The concrete use case I have is a string that needs to be converted to
Value
. The string could be either numerical in which case it should beValue::Number
or just a text, in which case it will beValue::String
.So I am using next code:
Writing
Value::from(number)
feels cleanerThe text was updated successfully, but these errors were encountered: