Implement DoubleEndedIterator for FlatMapIterator

This PR includes the changes from pull #7931 which add a useful method to Option.

Make .flat_map_() double-ended if the base iterator and the mapped-to iterator type are both double-ended.