pub struct VersionReq(/* private fields */);Expand description
A version requirement string as it appears in a manifest file.
This is deliberately permissive: it stores whatever bytes the manifest
contained (e.g. "^1.0", ">=2.0,<3.0", "*"), including the empty
string. No parsing, validation, trimming, or normalization is performed
by this type — ecosystems that need to parse a requirement (via semver,
node-semver, pep440_rs, etc.) do so from VersionReq::as_str, not
from this type. Note that deps-go’s GoDependency.version also uses this
type even though it holds an exact pinned version (e.g. "v1.9.1"), not a
range or constraint — Go modules don’t have a separate “requirement”
concept, so the exact version doubles as the requirement.
§Examples
use deps_core::VersionReq;
let req = VersionReq::new("^1.0");
assert_eq!(req.as_str(), "^1.0");
assert_eq!(req, "^1.0");Implementations§
Source§impl VersionReq
impl VersionReq
Sourcepub fn new(value: impl Into<String>) -> Self
pub fn new(value: impl Into<String>) -> Self
Wraps value as a VersionReq, unchanged.
This never fails and never modifies its input: an empty string is a
valid VersionReq, as is a string with surrounding whitespace.
§Examples
use deps_core::VersionReq;
let req = VersionReq::new(String::from(">=1.0"));
assert_eq!(req.as_str(), ">=1.0");Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the version requirement as a string slice.
§Examples
use deps_core::VersionReq;
let req = VersionReq::new("~1.2");
assert_eq!(req.as_str(), "~1.2");Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Consumes the VersionReq, returning the wrapped String.
§Examples
use deps_core::VersionReq;
let req = VersionReq::new("~1.2");
let owned: String = req.into_string();
assert_eq!(owned, "~1.2");Trait Implementations§
Source§impl AsRef<str> for VersionReq
impl AsRef<str> for VersionReq
Source§impl Clone for VersionReq
impl Clone for VersionReq
Source§fn clone(&self) -> VersionReq
fn clone(&self) -> VersionReq
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for VersionReq
impl Debug for VersionReq
Source§impl Display for VersionReq
impl Display for VersionReq
impl Eq for VersionReq
Source§impl From<&str> for VersionReq
impl From<&str> for VersionReq
Source§impl From<String> for VersionReq
impl From<String> for VersionReq
Source§impl Hash for VersionReq
impl Hash for VersionReq
Source§impl PartialEq for VersionReq
impl PartialEq for VersionReq
Source§fn eq(&self, other: &VersionReq) -> bool
fn eq(&self, other: &VersionReq) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialEq<&str> for VersionReq
impl PartialEq<&str> for VersionReq
Source§impl PartialEq<str> for VersionReq
impl PartialEq<str> for VersionReq
impl StructuralPartialEq for VersionReq
Auto Trait Implementations§
impl Freeze for VersionReq
impl RefUnwindSafe for VersionReq
impl Send for VersionReq
impl Sync for VersionReq
impl Unpin for VersionReq
impl UnsafeUnpin for VersionReq
impl UnwindSafe for VersionReq
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.