Skip to main content

index_path

Function index_path 

Source
pub fn index_path(name: &str) -> String
Expand description

The crates.io sparse-index path for a crate name, by cargo’s rule: 1- and 2-char names live under 1//2/, 3-char under 3/<first>/, and everything else under <first-two>/<next-two>/. The name is lower-cased.

use coding_tools::update::index_path;
assert_eq!(index_path("coding-tools"), "co/di/coding-tools");
assert_eq!(index_path("a"), "1/a");
assert_eq!(index_path("ab"), "2/ab");
assert_eq!(index_path("abc"), "3/a/abc");
assert_eq!(index_path("serde"), "se/rd/serde");