Skip to content

Commit

Permalink
Allow comparing Version by deriving PartialOrd and Ord, add constant …
Browse files Browse the repository at this point in the history
…with the version the bindings were compiled with
  • Loading branch information
antonilol committed Jun 14, 2024
1 parent 4d5a1d9 commit ed72bbb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/sdl2/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::fmt;
use crate::sys;

/// A structure that contains information about the version of SDL in use.
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug, PartialOrd, Ord)]
pub struct Version {
/// major version
pub major: u8,
Expand All @@ -19,6 +19,14 @@ pub struct Version {
}

impl Version {
/// The version of SDL that was used to generate the bindings. This may differ from the version
/// used at runtime, use [`version`] to get that.
pub const COMPILE_TIME_VERSION: Self = Self {
major: sys::SDL_MAJOR_VERSION as u8,
minor: sys::SDL_MINOR_VERSION as u8,
patch: sys::SDL_PATCHLEVEL as u8,
};

/// Convert a raw *SDL_version to Version.
pub fn from_ll(v: sys::SDL_version) -> Version {
Version {
Expand Down

0 comments on commit ed72bbb

Please sign in to comment.