With full credit where it is due: to @EH2406, who put the original together (here). Note that I'm doing a quick pass and confirming each of these as I get to them.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We expect the tarball to only contain a single directory, the | |
# same way that the builtin `fetchTarball' does. | |
{ stdenv, nix }: | |
{ url, | |
# Name we label this derivation with. | |
name, | |
# Hash of *extracted output directory*, | |
# as generated by `nix-hash --type sha256 --base32'. |
Rust has a built-in generic type called Option<T>
, so a value of type
Option<i32>
can be read as "I either have a valid 32-bit integer, or
nothing." Using it as a return type tells your callers that you might fail,
and makes sure that they handle that possibility correctly.
pub fn maybe_divide(x: i32, y: i32) -> Option<i32>
would be the signature of a function which might fail to produce a value