diff --git a/RustEnhanced.sublime-syntax b/RustEnhanced.sublime-syntax index 96db8f4f..f7ddbe29 100644 --- a/RustEnhanced.sublime-syntax +++ b/RustEnhanced.sublime-syntax @@ -71,6 +71,12 @@ contexts: 1: storage.modifier.rust 2: storage.type.type.rust 3: entity.name.type.rust + push: + - match: '=(?!=)' + scope: keyword.operator.rust + push: after-operator + - match: '(?=\S)' + pop: true - match: '\b(?:(pub)\s+)?(trait)\s+({{identifier}})\b' captures: @@ -129,7 +135,6 @@ contexts: - match: \breturn\b scope: keyword.control.rust - push: after-operator - match: \b(as|in|box)\b scope: keyword.operator.rust @@ -213,18 +218,14 @@ contexts: # match blocks containing just enums - match: '=>' scope: keyword.operator.rust - push: after-operator - match: '=(?!=)' scope: keyword.operator.rust - push: after-operator - match: '[;,]' - push: after-operator - match: ':' scope: punctuation.separator.rust - push: after-operator - match: '\.\.\.' scope: keyword.operator.rust @@ -446,6 +447,7 @@ contexts: pop: true type-any-identifier: + - include: comments - include: support-type - include: return-type - match: '&' diff --git a/syntax_test_rust.rs b/syntax_test_rust.rs index 538ad41f..1d852c4b 100644 --- a/syntax_test_rust.rs +++ b/syntax_test_rust.rs @@ -1097,4 +1097,39 @@ where T: AsRef; //^^^^^^^^^^^^^^^ meta.struct // ^^^ meta.struct meta.where storage.type -// ^ punctuation.terminator \ No newline at end of file +// ^ punctuation.terminator + +fn foo i32>(f: F) { +// ^^^^^^^ meta.generic comment + let lam = |time: i32 /* comment */, other: i32| { +// ^^^^^^^^^^^^^ meta.function.parameters comment + }; +} + +// mdo example +fn main() { + // exporting the monadic functions for the Iterator monad (similar + // to list comprehension) + use mdo::iter::{bind, ret, mzero}; + + let l = bind(1i32..11, move |z| + bind(1..z, move |x| + bind(x..z, move |y| + bind(if x * x + y * y == z * z { ret(()) } + else { mzero() }, + move |_| + ret((x, y, z)) + )))).collect::>(); + println!("{:?}", l); + + // the same thing, using the mdo! macro + let l = mdo! { + z =<< 1i32..11; + x =<< 1..z; +// ^^^ keyword.operator + y =<< x..z; + when x * x + y * y == z * z; + ret ret((x, y, z)) + }.collect::>(); + println!("{:?}", l); +}