Range should impl TryFrom<(Bound, Bound)>

And while on the subject, it seems like the other 5 Range types in std::ops should impl TryFrom<(Bound, Bound)> too.

Does this seem reasonable?

Cheers, ripytide

Can you say more about what you're trying to do where this would be useful?

It's possible you're looking for something like https://doc.rust-lang.org/std/slice/fn.range.html or impl RangeBounds instead.

I am trying to create an instance of some type K: RangeBounds<I> from two Bounds that I happen to have. Hence it would be nice if Range impl TryFrom<(Bound, Bound)> Minimal example to attempt to flip then end_bound() of some given RangeBound<I> type:

use std::ops::{Bound, RangeBounds};

fn flip_end_bound<I, Q, K>(range_bounds: &Q) -> Option<K>
	Q: RangeBounds<I>,
	K: TryFrom<(Bound<I>, Bound<I>)>,
	I: Clone,
	let flipped_end_bound = match range_bounds.end_bound() {
		Bound::Included(point) => Bound::Excluded(point),
		Bound::Excluded(point) => Bound::Included(point),
		Bound::Unbounded => Bound::Unbounded,


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.