0
点赞
收藏
分享

微信扫一扫

【Rust日报】2020-07-16 j4rs,一个在 Rust 中调用 Java 代码的 Crate

Rust 和 Go 的 gRPC 基准测试

关于 Rust 和 Go 的一些 gRPC 库的基准测试,reddit上有不少评论,讨论了大家关心的一些地方,有兴趣可以看一下。,详情可看原文

​​https://medium.com/@Rustling_gopher/benchmarking-grpc-in-rust-go-184545e7688a​​

​j4rs​,一个在 Rust 中调用 Java 代码的 Crate

j4rs 是 Rust 的一个库,提供了一些从 Rust 端调用 Java 函数的一些工具。

现在已经发布了 v0.12.0 版本。

Rust端代码大概是这个样子:

use j4rs::prelude::*;
use j4rs_derive::*;

#[call_from_java("io.github.astonbitecode.j4rs.example.RustSimpleFunctionCall.fnnoargs")]
fn my_function_with_no_args() {
println!("Hello from the Rust world!");
}

Java端的代码是这样的:

package io.github.astonbitecode.j4rs.example;

public class RustSimpleFunctionCall {
private static native void fnnoargs();

static {
System.loadLibrary("rustlib");
}

public void doCallNoArgs() {
fnnoargs();
}

}

具体请看原文:https://astonbitecode.github.io/blog/post/j4rs_0.12.0/

GitHub 仓库地址:https://github.com/astonbitecode/j4rs

Rust 中的函数重载

作者提供了一些思路在 Rust 中实现了函数重载,一个示例的代码:

#![feature(unboxed_closures, fn_traits, type_alias_impl_trait, impl_trait_in_bindings)]
use functionate::functionate;
use std::ops::Fn;

#[allow(non_upper_case_globals)]
static foo: impl Fn() -> &'static str + Fn(i32) -> i32 = {
struct Foo;
#[functionate]
impl Foo {
fn a(&self) -> &'static str { "bar" }
fn b(&self, x: i32) -> i32 { x * 2 }
}
Foo
};

fn main() {
println!("{}", foo());
println!("{}", foo(5));
}

具体请查看原文:https://medium.com/@nrabulinski/function-overloading-in-rust-d591aff64a03

用 Rust 编写内核驱动

作者在使用 Rust 重写了他的部分 Windows 内核驱动程序,并分享了一些经验,再次过程中的总结,详情请查看博客原文

查看reddit讨论区:https://www.reddit.com/r/rust/comments/hrwyl8/writing_a_kernel_driver_with_rust/

一个使用了三维拟合算法用来解决讲小盒子放入大盒子里的问题的一个 Crate

crates.io:https://crates.io/crates/bin_packer_3d/

doc:https://docs.rs/bin_packer_3d/1.0.0/bin_packer_3d/


举报

相关推荐

0 条评论