enum SourceKind {
    Git(GitReference),
    Path,
    Registry,
    SparseRegistry,
    LocalRegistry,
    Directory,
}
Expand description

The possible kinds of code source. Along with SourceIdInner, this fully defines the source.

Variants§

§

Git(GitReference)

A git repository.

§

Path

A local path.

§

Registry

A remote registry.

§

SparseRegistry

A sparse registry.

§

LocalRegistry

A local filesystem-based registry.

§

Directory

A directory-based registry.

Trait Implementations§

source§

impl Clone for SourceKind

source§

fn clone(&self) -> SourceKind

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SourceKind

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for SourceKind

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for SourceKind

Note that this is specifically not derived on SourceKind although the implementation here is very similar to what it might look like if it were otherwise derived.

The reason for this is somewhat obtuse. First of all the hash value of SourceKind makes its way into ~/.cargo/registry/index/github.com-XXXX which means that changes to the hash means that all Rust users need to redownload the crates.io index and all their crates. If possible we strive to not change this to make this redownloading behavior happen as little as possible. How is this connected to Ord you might ask? That’s a good question!

Since the beginning of time SourceKind has had #[derive(Hash)]. It for the longest time also derived the Ord and PartialOrd traits. In #8522, however, the implementation of Ord changed. This handwritten implementation forgot to sync itself with the originally derived implementation, namely placing git dependencies as sorted after all other dependencies instead of first as before.

This regression in #8522 (Rust 1.47) went unnoticed. When we switched back to a derived implementation in #9133 (Rust 1.52 beta) we only then ironically saw an issue (#9334). In #9334 it was observed that stable Rust at the time (1.51) was sorting git dependencies last, whereas Rust 1.52 beta would sort git dependencies first. This is because the PartialOrd implementation in 1.51 used #8522, the buggy implementation, which put git deps last. In 1.52 it was (unknowingly) restored to the pre-1.47 behavior with git dependencies first.

Because the breakage was only witnessed after the original breakage, this trait implementation is preserving the “broken” behavior. Put a different way:

  • Rust pre-1.47 sorted git deps first.
  • Rust 1.47 to Rust 1.51 sorted git deps last, a breaking change (#8522) that was never noticed.
  • Rust 1.52 restored the pre-1.47 behavior (#9133, without knowing it did so), and breakage was witnessed by actual users due to difference with 1.51.
  • Rust 1.52 (the source as it lives now) was fixed to match the 1.47-1.51 behavior (#9383), which is now considered intentionally breaking from the pre-1.47 behavior.

Note that this was all discovered when Rust 1.53 was in nightly and 1.52 was in beta. #9133 was in both beta and nightly at the time of discovery. For 1.52 #9383 reverted #9133, meaning 1.52 is the same as 1.51. On nightly (1.53) #9397 was created to fix the regression introduced by #9133 relative to the current stable (1.51).

That’s all a long winded way of saying “it’s weird that git deps hash first and are sorted last, but it’s the way it is right now”. The author of this comment chose to handwrite the Ord implementation instead of the Hash implementation, but it’s only required that at most one of them is hand-written because the other can be derived. Perhaps one day in the future someone can figure out how to remove this behavior.

source§

fn cmp(&self, other: &SourceKind) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<SourceKind> for SourceKind

source§

fn eq(&self, other: &SourceKind) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<SourceKind> for SourceKind

Forwards to Ord

source§

fn partial_cmp(&self, other: &SourceKind) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Eq for SourceKind

source§

impl StructuralEq for SourceKind

source§

impl StructuralPartialEq for SourceKind

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Comparable<K> for Qwhere Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 32 bytes

Size for each variant:

  • Git: 32 bytes
  • Path: 0 bytes
  • Registry: 0 bytes
  • SparseRegistry: 0 bytes
  • LocalRegistry: 0 bytes
  • Directory: 0 bytes