Skip to content

Instantly share code, notes, and snippets.

@hhatto
Created May 10, 2017 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hhatto/42da9aa40940dbee261b79c3dd692a26 to your computer and use it in GitHub Desktop.
Save hhatto/42da9aa40940dbee261b79c3dd692a26 to your computer and use it in GitHub Desktop.
extern "C" {
pub fn otama_open(otama: *mut *mut otama_t,
config_path: *const ::std::os::raw::c_char)
-> otama_status_t;
}
#[cfg(test)]
mod tests {
use super::*;
use std::mem;
use std::ffi::CString;
#[test]
fn test_otama_open() {
let config = CString::new("path.yaml").unwrap();
unsafe {
let &mut o = &mut mem::zeroed();
otama_open(&mut o as *mut *mut otama_t, config.as_ptr());
}
}
}
@hhatto
Copy link
Author

hhatto commented May 10, 2017

$ cargo test
   Compiling otama v0.1.0 (file:///Users/hattori-h/otama-rs)
error: cannot borrow immutable local variable `o` as mutable
  --> src/lib.rs:18:29
   |
17 |             let &mut o = &mut mem::zeroed();
   |                      - use `mut o` here to make mutable
18 |             otama_open(&mut o as *mut *mut otama_t, config.as_ptr());
   |                             ^ cannot borrow mutably

error: aborting due to previous error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment