Description
Hi,
I'm starting to experiment your fantastic library, especially to create lib for Lua.
One uses the rust-image lib: it's ok if the code don't access to the file system otherwise the process crashed (with the same error reported below).
Another experiment is an attempt with rust-tabular... but fails.
So I began to think that I/O is the problem and I write this example: saving a text file from Lua perfectly functional in "only Rust" code.
#![feature(phase)]
#[phase(plugin)]
extern crate lua_mod = "rust-hl-lua-modules";
#[export_lua_module]
pub mod save {// <-- must be the name of the Lua module
use std::io::File;
fn savefile() {
let p = Path::new("a-file.txt");
let mut file = match File::create(&p) {
Ok(f) => f,
Err(e) => fail!("file error: {}", e),
};
file.write(b"content");
}
#[lua_module_init]
fn init() {
println!("module initialized!")
}
}
Then I compile it with Cargo with this config:
[package]
name = "save"
version = "0.1.0"
authors = [ "my.username@my.email.com" ]
[[lib]]
name = "save" # the name of the executable to generate
crate_type = ["dylib"]
[dependencies.rust-hl-lua-modules]
git = "https://github.com/tomaka/rust-hl-lua"
In a terminal session the behaviour of the library is this:
roberto@roberto-desktop:~/Scrivania/test-save/test$ lua
Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio
> s = require "save"
module initialized!
> s.savefile()
You've met with a terrible fate, haven't you?
fatal runtime error: Could not unwind stack, error = 5
Istruzione non consentita (core dump creato)
Can you help me?
Is a question of local library installed on my system?
Thank you very much.
My dev platform is an Ubuntu 14.04 with ultimate version of Rust (0.12.0-pre-nightly 25741603f), Cargo and github library.