-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! [NFY] Wrap semver::Version as Lua type
- Loading branch information
Showing
2 changed files
with
20 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,29 @@ | ||
use mlua::prelude::*; | ||
use semver::Version; | ||
use std::ops::Deref; | ||
|
||
pub struct Semver { | ||
version: Version, | ||
pub version: Version, | ||
} | ||
|
||
impl Semver { | ||
pub fn new(version: &str) -> crate::Result<Self> { | ||
let version = Version::parse(version)?; | ||
Ok(Semver { version }) | ||
} | ||
} | ||
|
||
impl Deref for Semver { | ||
type Target = Version; | ||
fn deref(&self) -> &Version { | ||
&self.version | ||
} | ||
} | ||
|
||
impl IntoLua for Semver { | ||
#[inline] | ||
fn into_lua(self, lua: &Lua) -> LuaResult<LuaValue> { | ||
let semver = lua.create_table()?; | ||
Ok(LuaValue::Table(semver)) | ||
//"just an str".into_lua(lua) | ||
} | ||
} | ||
|
||
pub fn foo() -> crate::Result<()> { | ||
eprintln!("Run"); | ||
Ok(()) | ||
} |