diff --git a/rusile/src/lib.rs b/rusile/src/lib.rs index 41fa3d141..42a00bad1 100644 --- a/rusile/src/lib.rs +++ b/rusile/src/lib.rs @@ -8,9 +8,7 @@ use mlua::prelude::*; fn rusile(lua: &Lua) -> LuaResult { let exports = lua.create_table().unwrap(); exports.set("demo", LuaFunction::wrap_raw(sile::rusile_demo))?; - //exports.set( - // "semver", - // LuaFunction::wrap_raw(sile::types::semver::Semver::new), - //)?; + //dbg!(sile::types::semver::new); + //exports.set("semver", LuaFunction::wrap_raw(sile::types::semver::new))?; Ok(exports) } diff --git a/src/types/semver.rs b/src/types/semver.rs index 2342ca397..b17d995e4 100644 --- a/src/types/semver.rs +++ b/src/types/semver.rs @@ -3,19 +3,29 @@ use semver::Version; use std::ops::Deref; pub struct Semver { - pub version: Version, + pub version: Option, } impl Semver { - pub fn new(version: &str) -> crate::Result { - let version = Version::parse(version)?; - Ok(Semver { version }) + pub fn new(version: Option<&str>) -> crate::Result { + let version = match version { + Some(str) => Self { + version: Some(Version::parse(str)?), + }, + None => Self { version: None }, + }; + Ok(version) } } +//pub fn new(version: &str) -> crate::Result { +// let version = Version::parse(version)?; +// Ok(Semver { version }) +//} + impl Deref for Semver { - type Target = Version; - fn deref(&self) -> &Version { + type Target = Option; + fn deref(&self) -> &Option { &self.version } }