我可以用整数作为输入调用testrust程序并很好地处理这些问题,即使不引用ctypes
。然而,我似乎得不到一根不生锈的绳子。在
这是我的测试生锈代码:
use std::env;
#[no_mangle]
pub extern fn helloworld(names: &str ) {
println!("{}", names);
println!("helloworld...");
}
#[no_mangle]
pub extern fn ihelloworld(names: i32 ) {
println!("{}", names);
println!("ihelloworld...");
}
ihelloworld
工作正常。但是,即使我使用ctypes
,我也找不到一种将python中的字符串转换为Rust的方法。在
下面是调用Python的代码:
^{pr2}$输出为:
1
ihelloworld...
Segmentation fault (core dumped)
ihellowworld
Rust函数工作正常,但我似乎无法使helloworld
工作。在
我使用了the Rust FFI Omnibus,现在我的代码似乎可以正常工作。在
从Python发送的字符串应该在Rust中表示为^{} 。在
相关问题 更多 >
编程相关推荐