Do I understand it correctly?

The below definition, in my opinion has unnecessary param Q, as the trait bound provided is identical to param P. Am I correct or yet again, I don't understand?

pub fn copy_items<P, Q>(from: &[P], to: Q, options: &dir::CopyOptions) 
where
    P: AsRef<Path>,
    Q: AsRef<Path>,
{
}
1 Like

No. The current signature of the function says that both P and Q implements AsRef<Path>. And they can be different types because the definition allows it. But using P instead of Q would mean that both from and to parameters have the same type. P only describes one type, but P and Q describes two potentially different types.

4 Likes

Thanks, well explained.

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.