Skip to content

Instantly share code, notes, and snippets.

@h14i
Created May 22, 2016 03:16
Show Gist options
  • Save h14i/ed1382481a14ee54e9613fa49e1ca2ad to your computer and use it in GitHub Desktop.
Save h14i/ed1382481a14ee54e9613fa49e1ca2ad to your computer and use it in GitHub Desktop.
" find_rust_std.vim
scriptencoding utf-8
function! FindRustStd(fname)
let fname = '*' . substitute(tolower(a:fname), '::', '/', 'g') . '.rs'
" echo fname
let found = globpath(s:path, fname)
if found != ''
return found
endif
let fname = substitute(fname, '/[^/]\{-}\.rs$', '/mod.rs', '')
" echo fname
let found = globpath(s:path, fname)
if found != ''
return found
endif
let fname = substitute(fname, '/[^/]\{-}\.rs$', '*', '')
" echo fname
let found = globpath(s:path, fname)
if found != ''
return found
endif
return ''
endfunction
let s:path = expand('$RUST_SRC_PATH')
let s:duration = 'std::time::Duration'
echo FindRustStd(s:duration)
echo ""
let s:instant = 'std::time::Instant'
echo FindRustStd(s:instant)
echo ""
let s:mutex = 'std::sync::mutex::Arc'
echo RustIncludeExpr(s:mutex)
echo ""
let s:chars = 'std::io::Chars'
echo RustIncludeExpr(s:chars)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment