Class: Rouge::Lexers::Rust

Inherits:
RegexLexer show all
Defined in:
lib/rouge/lexers/rust.rb

Constant Summary

Constants inherited from RegexLexer

RegexLexer::MAX_NULL_SCANS

Constants included from Token::Tokens

Token::Tokens::Num, Token::Tokens::Str

Instance Attribute Summary

Attributes inherited from Rouge::Lexer

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RegexLexer

append, #delegate, get_state, #get_state, #goto, #group, #groups, #in_state?, #pop!, prepend, #push, #recurse, replace_state, #reset!, #reset_stack, #stack, start, start_procs, #state, state, #state?, state_definitions, states, #step, #stream_tokens, #token

Methods inherited from Rouge::Lexer

aliases, all, #as_bool, #as_lexer, #as_list, #as_string, #as_token, assert_utf8!, #bool_option, continue_lex, #continue_lex, debug_enabled?, demo, demo_file, desc, detectable?, disable_debug!, enable_debug!, filenames, find, find_fancy, guess, guess_by_filename, guess_by_mimetype, guess_by_source, guesses, #hash_option, #initialize, #lex, lex, #lexer_option, #list_option, lookup_fancy, mimetypes, option, option_docs, #reset!, #stream_tokens, #string_option, tag, #tag, title, #token_option, #with

Methods included from Token::Tokens

token

Constructor Details

This class inherits a constructor from Rouge::Lexer

Class Method Details

.builtinsObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rouge/lexers/rust.rb', line 35

def self.builtins
  @builtins ||= Set.new %w(
    Add BitAnd BitOr BitXor bool c_char c_double c_float char
    c_int clock_t c_long c_longlong Copy c_schar c_short
    c_uchar c_uint c_ulong c_ulonglong c_ushort c_void dev_t DIR
    dirent Div Eq Err f32 f64 FILE float fpos_t
    i16 i32 i64 i8 isize Index ino_t int intptr_t mode_t Mul
    Neg None off_t Ok Option Ord Owned pid_t ptrdiff_t
    Send Shl Shr size_t Some ssize_t str Sub time_t
    u16 u32 u64 u8 usize uint uintptr_t
    Box Vec String Rc Arc
    u128 i128 Result Sync Pin Unpin Sized Drop drop Fn FnMut FnOnce
    Clone PartialEq PartialOrd AsMut AsRef From Into Default
    DoubleEndedIterator ExactSizeIterator Extend IntoIterator Iterator
    FromIterator ToOwned ToString TryFrom TryInto
  )
end

.detect?(text) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/rouge/lexers/rust.rb', line 19

def self.detect?(text)
  return true if text.shebang? 'rustc'
end

.keywordsObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rouge/lexers/rust.rb', line 23

def self.keywords
  @keywords ||= %w(
    as async await break const continue crate dyn else enum extern false
    fn for if impl in let log loop match mod move mut pub ref return self
    Self static struct super trait true type unsafe use where while
    abstract become box do final macro
    override priv typeof unsized virtual
    yield try
    union
  )
end

Instance Method Details

#macro_closed?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/rouge/lexers/rust.rb', line 53

def macro_closed?
  @macro_delims.values.all?(&:zero?)
end