Last active
February 4, 2019 06:21
-
-
Save srishanbhattarai/2549555d305c1eb4cfd97120f7c6fe1e to your computer and use it in GitHub Desktop.
Example Calculator struct for the Neovim plugin blog post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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