fix(pkgid): Allow open namespaces in PackageIdSpec's by epage · Pull Request #14467 · rust-lang/cargo (original) (raw)

Yeah, I should have called out this non-obvious design choice.

Yes, we always return Some(version). However, that makes things nicer in the caller. One caller doesn't care, they can just Some(version) or pass it through, depending on what we do. The other caller would require a .map(|(name, version)| (name, Some(version)) which when added to let (name, version) = parse_spec(spec)?.unwrap_or_else(|| (spec.to_owned(), None)); was making things more complicated than it seemed worth it (or I'd break this out into a match). Since the scope of parse_spec is hyper-local, it felt okay-ish to consider how the callers used it for what the API looked like. I already had to do that once by the fact that each caller handles the lack of version differently.