Skip to content

Instantly share code, notes, and snippets.

@srishanbhattarai
Last active February 4, 2019 06:21
Show Gist options
  • Save srishanbhattarai/2549555d305c1eb4cfd97120f7c6fe1e to your computer and use it in GitHub Desktop.
Save srishanbhattarai/2549555d305c1eb4cfd97120f7c6fe1e to your computer and use it in GitHub Desktop.
Example Calculator struct for the Neovim plugin blog post
struct Calculator;
impl Calculator {
fn new() -> Calculator {
Calculator {}
}
// Add a vector of numbers.
fn add(&self, nums: Vec<i64>) -> i64 {
nums.iter().sum::<i64>()
}
// Multiply two numbers
fn multiply(&self, p: i64, q: i64) -> i64 {
p * q
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment