Search code examples
rustrustup

Where is checksumValid() defined?


I am working from a compliance perspective. I am struggling with the simplest thing, how to find the source for various functions that are called by rustup.

For example, the rustup source code references checksumValid, but I can't find it defined anywhere. I searched stackoverflow, I searched Google, etc.

I'd appreciate help finding checksumValid, but more importantly, what is wrong with my approach?

pub enum Notification<'a> {
...
NoUpdateHash(&'a Path),
ChecksumValid(&'a str),
SignatureValid(&'a str, &'a PgpPublicKey),
...

Solution

  • ChecksumValid(&'a str) here is not actually a function but rather one of many possible values of an enum Notification defined in this line. While the () is usually associated with functions in rust it can denote other things as well. In this case it denotes one possible value of the enum that contains some data that is of type &str with a lifetime of 'a. This is the definition of this value, in this line right here.

    You might want to read this to understand the syntax.