mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Add documentation to PackageName::normalize
(#263)
This commit is contained in:
parent
89dad0c9ad
commit
e00d208318
1 changed files with 5 additions and 0 deletions
|
@ -24,6 +24,11 @@ impl Display for PackageName {
|
|||
static NAME_NORMALIZE: Lazy<Regex> = Lazy::new(|| Regex::new(r"[-_.]+").unwrap());
|
||||
|
||||
impl PackageName {
|
||||
/// Create a normalized representation of a package name.
|
||||
///
|
||||
/// Converts the name to lowercase and collapses any run of the characters `-`, `_` and `.`
|
||||
/// down to a single `-`, e.g., `---`, `.`, and `__` all get converted to just `-`.
|
||||
///
|
||||
/// See: <https://packaging.python.org/en/latest/specifications/name-normalization/>
|
||||
pub fn normalize(name: impl AsRef<str>) -> Self {
|
||||
// TODO(charlie): Avoid allocating in the common case (when no normalization is required).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue