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
When trying to match the elements of a Json array by their type, it seems it is not (easily) possible to do it for strings:
let data = array!["fii", "foo", 4];for i in data.members(){println!("examining {}", i);match i {JsonValue::Number(_) => println!(" it's a number"),JsonValue::String(_) => println!(" it's a string"),
_ if i.is_string() => println!(" it's really a string"),
_ => println!(" it's something else"),}
While the JsonValue::Number arm works as expected, the JsonValue::String arm is never entered. Only _ if i.is_string() works. Perhaps this is the expected behaviour (I'm a rust beginner so I am not sure), but certainly it is not very intuitive...
The text was updated successfully, but these errors were encountered:
When trying to match the elements of a Json array by their type, it seems it is not (easily) possible to do it for strings:
While the
JsonValue::Number
arm works as expected, theJsonValue::String
arm is never entered. Only_ if i.is_string()
works. Perhaps this is the expected behaviour (I'm a rust beginner so I am not sure), but certainly it is not very intuitive...The text was updated successfully, but these errors were encountered: