Overcome crates.io squatting in one line of YAML?

40 points paldn

I haven't seen this shared and figured it may not be widely known. It may be of interest to those of you frustrated by name squatting and lack of namespaces in crates.io.

Say you have developed the greatest math package of all time. And you go check https://crates.io/crates/math, the natural place for your great library to live, and alas it is taken by user troll420. Drat. Will have to think of some other name.

Well.. not really. You can name your library whatever you want:

[lib]                         
name="math"

Your users can now be delighted with your clean math::matmul API. To publish your crate on https://crates.io, you will still need to choose a unique package name. So for example, you could prefix the library with your username or organization name:

[package]                       
name = "user_math"          
version = "0.1.0"               
edition = "2021"                
[lib]                         
name="math"

There is nothing stopping other users from using your prefix, so, it doesn't carry the same "named authority" benefits as proper namespaces might.

You could also call it mathlib or math_framework or whatever. The library is still math.