From e00d208318392a7e7f74bc13d5ca4447cc599c91 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Tue, 31 Oct 2023 15:24:08 -0500 Subject: [PATCH] Add documentation to `PackageName::normalize` (#263) --- crates/puffin-package/src/package_name.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/puffin-package/src/package_name.rs b/crates/puffin-package/src/package_name.rs index f161f3172..2b2e22b5a 100644 --- a/crates/puffin-package/src/package_name.rs +++ b/crates/puffin-package/src/package_name.rs @@ -24,6 +24,11 @@ impl Display for PackageName { static NAME_NORMALIZE: Lazy = 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: pub fn normalize(name: impl AsRef) -> Self { // TODO(charlie): Avoid allocating in the common case (when no normalization is required).