Skip to content

Instantly share code, notes, and snippets.

@helloobaby
Created October 28, 2022 10:46
Show Gist options
  • Select an option

  • Save helloobaby/c41e76711a23b2bf1488b8f7609383ec to your computer and use it in GitHub Desktop.

Select an option

Save helloobaby/c41e76711a23b2bf1488b8f7609383ec to your computer and use it in GitHub Desktop.
rust 模板函数
use warp::Filter;
fn template_fn<F:std::ops::Add<Output=F> + From<i32> >(mut num: F) -> F{
num = num + 2.into();
num
}
fn main() {
println!("{}",template_fn(2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment