rextendr我正在尝试使用R 包和 Rust箱来学习如何连接 Rust 和 R(除了学习 Rust 本身)extendr。当我在 R 函数的输入中Expected a vector type.使用时遇到错误。:
下面是一个简单函数的示例,TRUE如果输入向量中的所有值都为正,则返回,FALSE否则返回。当我在输入中使用时它似乎工作正常c(),但当我使用:.
library(rextendr)\n\n# create a Rust function that checks if all values in the input are\n# greater than 0\nrust_function(\n "fn all_positive(input: &[f64]) -> bool {\n let mut out = true;\n for i in input.iter() {\n if *i <= 0.0 {\n out = false;\n break\n } \n }\n out\n }"\n)\n#> \xe2\x84\xb9 build directory: …Run Code Online (Sandbox Code Playgroud)