This repository has been archived by the owner on Nov 14, 2021. It is now read-only.
forked from dobkeratops/rustfind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rsfind.rs
83 lines (68 loc) · 1.64 KB
/
rsfind.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
extern crate syntax;
extern crate rustc;
//extern crate extra;
//pub static ctxtkey: local_data::Key<@DocContext> = &local_data::Key;
pub macro_rules! if_some {
($b:ident in $a:expr then $c:expr)=>(
match $a {
Some($b)=>$c,
None=>{}
}
);
}
pub macro_rules! tlogi{
($($a:expr),*)=>(println((file!()+":"+line!().to_str()+": " $(+$a.to_str())*) ))
}
pub macro_rules! logi{
($($a:expr),*)=>(println(""$(+$a.to_str())*) )
}
//macro_rules! dump{ ($a:expr)=>(logi!(fmt!("%s=%?",stringify!($a),$a).indent(2,160));)}
macro_rules! dump{ ($($a:expr),*)=>
( { let mut txt=~"";
$( { txt=txt.append(
format!("{:s}={:?}",stringify!($a),$a)+",")
}
);*;
logi!(txt);
}
)
}
pub macro_rules! if_some {
($b:ident in $a:expr then $c:expr)=>(
match $a {
Some($b)=>$c,
None=>{}
}
);
($b:ident in $a:expr then $c:expr _else $d:expr)=>(
match $a {
Some($b)=>$c,
None=>{$d}
}
);
}
#[deriving(Clone, Eq, Encodable, Decodable)]
pub enum ShowDefMode {
SDM_Line=0,
SDM_LineCol=1,
SDM_Source=2,
SDM_GeditCmd=3
}
pub trait MyOption<T> {
fn for_some(&self, f: |&T|);
fn do_some<R>(&self, f: |&T| -> R) -> Option<R>;
}
impl<T> MyOption<T> for Option<T>{
fn for_some(&self, f: |&T|) {
match self {
&None=>{},
&Some(ref t)=>f(t)
}
}
fn do_some<R>(&self, f: |&T| -> R)->Option<R> {
match self {
&None=>None,
&Some(ref t)=>Some(f(t))
}
}
}