pub enum RequestedVersion {
Any,
MajorOnly(ComponentSize),
Exact(ComponentSize, ComponentSize),
}
Expand description
The version of Python being searched for.
The constraints of what is being searched for can very from being
open-ended/broad (i.e. RequestedVersion::Any
) to as specific as
major.minor
(e.g. RequestedVersion::Exact
to search for Python 3.10).
Variants§
Any
Any version of Python is acceptable.
MajorOnly(ComponentSize)
A major version of Python is required (e.g. 3.x
).
Exact(ComponentSize, ComponentSize)
A specific major.minor
version of Python is required (e.g. 3.9
).
Implementations§
Source§impl RequestedVersion
impl RequestedVersion
Sourcepub fn env_var(self) -> Option<String>
pub fn env_var(self) -> Option<String>
Returns the String
representing the environment variable for the
requested version (if applicable).
§Examples
Searching for RequestedVersion::Any
provides an environment variable
which can be used to specify the default version of Python to use
(e.g. 3.10
).
let any_version = python_launcher::RequestedVersion::Any;
assert_eq!(Some("PY_PYTHON".to_string()), any_version.env_var());
RequestedVersion::MajorOnly
uses an environment variable which is
scoped to providing the default version for when the major version is
only specified.
let major_version = python_launcher::RequestedVersion::MajorOnly(3);
assert_eq!(Some("PY_PYTHON3".to_string()), major_version.env_var());
When RequestedVersion::Exact
is specified, there is no “default” to
provide/interpreter, and so no environment variable exists.
let exact_version = python_launcher::RequestedVersion::Exact(3, 10);
assert!(exact_version.env_var().is_none());
Trait Implementations§
Source§impl Clone for RequestedVersion
impl Clone for RequestedVersion
Source§fn clone(&self) -> RequestedVersion
fn clone(&self) -> RequestedVersion
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more