What is "upstream crates"?

What is "upstream crates"? I don't understand what "upstream" means in this concept? Can you give me a concrete example?

Crates you depend on.

Probably you're talking about something like this error:

trait Trait {}
impl<T: From<()>> Trait for T {}
impl Trait for String {}
error[E0119]: conflicting implementations of trait `Trait` for type `std::string::String`
 --> src/lib.rs:3:1
2 | impl<T: From<()>> Trait for T {}
  | ----------------------------- first implementation here
3 | impl Trait for String {}
  | ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::string::String`
  = note: upstream crates may add a new impl of trait `std::convert::From<()>` for type `std::string::String` in future versions

The idea is that if stdlib (an upstream crate you depend on) wanted to implement From<()> for their own struct String at some point in the future, they should be able to do so without breaking downstream crates (like your own). If both of the implementations were allowed, there would be more than one implementation once From<()> was implemented for String, and your crate would break then.


The metaphor is a river, where "upstream" means where the water is coming from, and "downstream" is where the water is going to (because they are respectively literally above and below)


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.