Skip to content

Commit 0576ef2

Browse files
committed
Add Rust snippets
1 parent d153af6 commit 0576ef2

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

snippets/rust-mode/display

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# -*- mode: snippet -*-
2+
# name: impl Display for Type { fn fmt (...) }
3+
# key: display
4+
# --
5+
impl Display for ${1:Type} {
6+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
7+
write!(f, "$0")
8+
}
9+
}

snippets/rust-mode/from

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- mode: snippet -*-
2+
# name: impl From<From> for Type { fn from(...) }
3+
# key: from
4+
# --
5+
impl From<${1:From}> for ${2:Type} {
6+
fn from(source: $1) -> Self {
7+
$0
8+
Self { }
9+
}
10+
}

snippets/rust-mode/fromstr

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# -*- mode: snippet -*-
2+
# name: impl FromStr for Type { fn from_str(...) }
3+
# key: fromstr
4+
# --
5+
impl FromStr for ${1:Type} {
6+
type Err = ${2:Error};
7+
8+
fn from_str(s: &str) -> Result<Self, Self::Err> {
9+
Ok(Self{})
10+
}
11+
}

snippets/rust-mode/result

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# -*- mode: snippet -*-
2+
# name: Result<Type, failure::Error>
3+
# key: result
4+
# --
5+
Result<${1:Type}, ${2:failure::Error}>

0 commit comments

Comments
 (0)