pub struct ExactVersion {
pub major: ComponentSize,
pub minor: ComponentSize,
}
Expand description
Specifies the major.minor
version of a Python executable.
This struct is typically used to represent a found executable’s version.
Fields§
§major: ComponentSize
The major version of Python, e.g. 3
of 3.10
.
minor: ComponentSize
The minor version of Python, e.g. 10
of 3.10
.
Implementations§
Source§impl ExactVersion
impl ExactVersion
Sourcepub fn new(major: ComponentSize, minor: ComponentSize) -> Self
pub fn new(major: ComponentSize, minor: ComponentSize) -> Self
Construct an instance of ExactVersion
.
Sourcepub fn from_path(path: &Path) -> Result<Self>
pub fn from_path(path: &Path) -> Result<Self>
Constructs a ExactVersion
from a pythonX.Y
file path.
§Errors
If the Path
is missing a file name component,
Error::FileNameMissing
is returned.
If the file name is not formatted appropriately,
Error::PathFileNameError
is returned.
When the Path
cannot be converted to a &str
,
Error::FileNameToStrError
is returned.
§Examples
let expected = python_launcher::ExactVersion::new(3, 10);
let executable_path = std::path::Path::new("python3.10");
let exact_version = python_launcher::ExactVersion::from_path(executable_path);
assert_eq!(Ok(expected), exact_version);
Sourcepub fn supports(&self, requested: RequestedVersion) -> bool
pub fn supports(&self, requested: RequestedVersion) -> bool
Tests whether this ExactVersion
satisfies the RequestedVersion
.
§Examples
let py3_10 = python_launcher::ExactVersion::new(3, 10);
let any_version = python_launcher::RequestedVersion::Any;
let py3_version = python_launcher::RequestedVersion::MajorOnly(3);
let py3_10_version = python_launcher::RequestedVersion::Exact(3, 10);
assert!(py3_10.supports(any_version));
assert!(py3_10.supports(py3_version));
assert!(py3_10.supports(py3_10_version));
Trait Implementations§
Source§impl Clone for ExactVersion
impl Clone for ExactVersion
Source§fn clone(&self) -> ExactVersion
fn clone(&self) -> ExactVersion
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ExactVersion
impl Debug for ExactVersion
Source§impl Display for ExactVersion
impl Display for ExactVersion
Source§impl From<ExactVersion> for RequestedVersion
impl From<ExactVersion> for RequestedVersion
Source§fn from(version: ExactVersion) -> Self
fn from(version: ExactVersion) -> Self
Converts to this type from the input type.
Source§impl FromStr for ExactVersion
impl FromStr for ExactVersion
Source§impl Hash for ExactVersion
impl Hash for ExactVersion
Source§impl Ord for ExactVersion
impl Ord for ExactVersion
Source§fn cmp(&self, other: &ExactVersion) -> Ordering
fn cmp(&self, other: &ExactVersion) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for ExactVersion
impl PartialEq for ExactVersion
Source§impl PartialOrd for ExactVersion
impl PartialOrd for ExactVersion
impl Copy for ExactVersion
impl Eq for ExactVersion
impl StructuralPartialEq for ExactVersion
Auto Trait Implementations§
impl Freeze for ExactVersion
impl RefUnwindSafe for ExactVersion
impl Send for ExactVersion
impl Sync for ExactVersion
impl Unpin for ExactVersion
impl UnwindSafe for ExactVersion
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
Mutably borrows from an owned value. Read more