Skip to content

Commit

Permalink
[NFY] Wrap semver::Version as Lua type
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Oct 10, 2024
1 parent a65dc01 commit c955bbf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rusile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ use mlua::prelude::*;
fn rusile(lua: &Lua) -> LuaResult<LuaTable> {
let exports = lua.create_table().unwrap();
exports.set("demo", LuaFunction::wrap_raw(sile::rusile_demo))?;
exports.set("foo", LuaFunction::wrap_raw(sile::types::semver::foo))?;
exports.set("semver", LuaTable::wrap(sile::types::semver::Semver))?;
Ok(exports)
}
14 changes: 14 additions & 0 deletions src/types/semver.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
use mlua::prelude::*;
use semver::Version;

pub struct Semver {
version: Version,

Check failure on line 5 in src/types/semver.rs

View workflow job for this annotation

GitHub Actions / clippy

field `version` is never read

error: field `version` is never read --> src/types/semver.rs:5:5 | 4 | pub struct Semver { | ------ field in this struct 5 | version: Version, | ^^^^^^^ | = note: `-D dead-code` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(dead_code)]`
}

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(())
Expand Down

0 comments on commit c955bbf

Please sign in to comment.