diff --git a/snippets/rust-mode/display b/snippets/rust-mode/display new file mode 100644 index 0000000..1764f67 --- /dev/null +++ b/snippets/rust-mode/display @@ -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") + } +} diff --git a/snippets/rust-mode/from b/snippets/rust-mode/from new file mode 100644 index 0000000..e04e7f0 --- /dev/null +++ b/snippets/rust-mode/from @@ -0,0 +1,10 @@ +# -*- mode: snippet -*- +# name: impl From for Type { fn from(...) } +# key: from +# -- +impl From<${1:From}> for ${2:Type} { + fn from(source: $1) -> Self { + $0 + Self { } + } +} diff --git a/snippets/rust-mode/fromstr b/snippets/rust-mode/fromstr new file mode 100644 index 0000000..891751c --- /dev/null +++ b/snippets/rust-mode/fromstr @@ -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 { + Ok(Self{}) + } +} diff --git a/snippets/rust-mode/result b/snippets/rust-mode/result new file mode 100644 index 0000000..6996dd4 --- /dev/null +++ b/snippets/rust-mode/result @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: Result +# key: result +# -- +Result<${1:Type}, ${2:failure::Error}> \ No newline at end of file