Skip to content

Commit

Permalink
Add Span::def_site-the-API
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Nov 21, 2017
1 parent 5d65807 commit e6085b7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,21 @@ impl TokenStream {
#[derive(Copy, Clone)]
pub struct Span(imp::Span);

#[doc(hidden)]
impl Default for Span {
fn default() -> Span {
Span(imp::Span::default())
Span(imp::Span::def_site())
}
}

impl Span {
pub fn call_site() -> Span {
Span(imp::Span::call_site())
}

pub fn def_site() -> Span {
Span(imp::Span::def_site())
}
}

#[derive(Clone, Debug)]
Expand Down
6 changes: 5 additions & 1 deletion src/stable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,17 @@ impl IntoIterator for TokenStream {
}
}

#[derive(Clone, Copy, Default, Debug)]
#[derive(Clone, Copy, Debug)]
pub struct Span;

impl Span {
pub fn call_site() -> Span {
Span
}

pub fn def_site() -> Span {
Span
}
}

#[derive(Copy, Clone)]
Expand Down
4 changes: 1 addition & 3 deletions src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,8 @@ impl Span {
pub fn call_site() -> Span {
Span(proc_macro::Span::call_site())
}
}

impl Default for Span {
fn default() -> Span {
pub fn def_site() -> Span {
Span(proc_macro::Span::def_site())
}
}
Expand Down

0 comments on commit e6085b7

Please sign in to comment.