pub trait VersionProvider {
// Required method
fn version() -> Version;
}
Expand description
A trait that provides a version.
Implementers of this trait must define how to return the version associated with them. This is useful for encapsulating versioning logic within various components or libraries.
§Examples
A simple implementation of VersionProvider
:
use app_version::{Version, VersionProvider};
struct MySoftware;
impl VersionProvider for MySoftware {
fn version() -> Version {
Version::new(1, 0, 0)
}
}
let my_version = MySoftware::version();
assert_eq!(my_version, Version::new(1, 0, 0 ));
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.