Merge pull request #285 from r-darwish/rust-snippets

Add Rust snippets
This commit is contained in:
Andrea Crotti 2018-09-22 20:28:15 +01:00 committed by GitHub
commit 1d1ea6f20c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# name: impl Display for Type { fn fmt (...) }
# key: display
# --
impl Display for ${1:Type} {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "$0")
}
}

10
snippets/rust-mode/from Normal file
View File

@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: impl From<From> for Type { fn from(...) }
# key: from
# --
impl From<${1:From}> for ${2:Type} {
fn from(source: $1) -> Self {
$0
Self { }
}
}

View File

@ -0,0 +1,11 @@
# -*- mode: snippet -*-
# name: impl FromStr for Type { fn from_str(...) }
# key: fromstr
# --
impl FromStr for ${1:Type} {
type Err = ${2:Error};
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Self{})
}
}

View File

@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: Result<Type, failure::Error>
# key: result
# --
Result<${1:Type}, ${2:failure::Error}>