Skip to main content

is_full_semver_shape

Function is_full_semver_shape 

Source
pub fn is_full_semver_shape(s: &str) -> bool
Expand description

Whether s has the shape of a full major.minor.patch version.

An optional leading v/V, three dot-separated all-digit components, and an optional SemVer-style prerelease/build suffix introduced by - or + (accepted, but not itself validated beyond “starts here”).

Hand-rolled rather than pulled in via the regex crate: this is consulted from bare_requirement_policy in deps-core, the workspace’s most-depended-on crate, which has no regex dependency today — equivalent to the pattern ^v?\d+\.\d+\.\d+(?:[-+].*)?$. Shared verbatim by deps-github-actions’s SHA-comment-tag parsing rule so the two mechanisms can never silently diverge on what counts as a full version (e.g. v4.2.0-beta.1 must be treated identically by both).

§Examples

use deps_core::lsp_helpers::is_full_semver_shape;

assert!(is_full_semver_shape("v4.2.0"));
assert!(is_full_semver_shape("4.2.0-beta.1"));
assert!(!is_full_semver_shape("v4"));
assert!(!is_full_semver_shape("v4.2"));
assert!(!is_full_semver_shape("not-a-version"));