Constructing a generic self

I'm trying to add some helpers to tabled, and there is something about Rust and generics that I don't seem to be getting. At all..

/// Row denotes a set of cells on given rows on a `Grid`
pub struct Row<R: RangeBounds<usize>>(pub R);

impl<R: RangeBounds<usize>> Row<R> {
    pub fn single(row: usize) -> Self {

And the error is

mismatched types
expected type parameter `R`
           found struct `std::ops::RangeInclusive<usize>`

The problem here is that the caller of single() gets to pick the type of R, but single() always produces a Row<RangeInclusive<usize>>. I imagine you want to make that the output type of the function, either on the impl block or on the function itself.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.