filterfunction

What's the most idiomatic way of working with an Iterator of Results? [duplicate]

ぐ巨炮叔叔 提交于 2019-11-30 13:53:18
问题 This question already has answers here : How do I stop iteration and return an error when Iterator::map returns a Result::Err? (2 answers) Closed 7 months ago . I have code like this: let things = vec![/* ...*/]; // e.g. Vec<String> things .map(|thing| { let a = try!(do_stuff(thing)); Ok(other_stuff(a)) }) .filter(|thing_result| match *thing_result { Err(e) => true, Ok(a) => check(a), }) .map(|thing_result| { let a = try!(thing_result); // do stuff b }) .collect::<Result<Vec<_>, _>>() In

What's the most idiomatic way of working with an Iterator of Results? [duplicate]

♀尐吖头ヾ 提交于 2019-11-30 08:31:28
This question already has an answer here: How do I stop iteration and return an error when Iterator::map returns a Result::Err? 2 answers I have code like this: let things = vec![/* ...*/]; // e.g. Vec<String> things .map(|thing| { let a = try!(do_stuff(thing)); Ok(other_stuff(a)) }) .filter(|thing_result| match *thing_result { Err(e) => true, Ok(a) => check(a), }) .map(|thing_result| { let a = try!(thing_result); // do stuff b }) .collect::<Result<Vec<_>, _>>() In terms of semantics, I want to stop processing after the first error. The above code works, but it feels quite cumbersome. Is there

How can I get list of properties in an object in Actionscript?

雨燕双飞 提交于 2019-11-28 06:47:25
I have a dataprovider and a filterfunction for my array that's assigned to my dataprovider. How can I get a list of the properties that are in each row of the dataprovider (item.data) as it gets passed to the filterfunction? For instance, if my object contained: Object name email address Then I would want, in my filterfunction to be able to look at name, email and address. Unfortunately, I don't know what these properties will be before hand. Any ideas? If it's a dynamic object I believe you can just do something like this: var obj:Object; // I'm assuming this is your object for(var id:String