syntax: parse const fn for free functions and inherent methods.
This commit is contained in:
committed by
Niko Matsakis
parent
bc6318d2be
commit
af3795721c
@@ -35,6 +35,10 @@ pub struct VisSpace(pub Option<ast::Visibility>);
|
||||
/// space after it.
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct UnsafetySpace(pub ast::Unsafety);
|
||||
/// Similarly to VisSpace, this structure is used to render a function constness
|
||||
/// with a space after it.
|
||||
#[derive(Copy)]
|
||||
pub struct ConstnessSpace(pub ast::Constness);
|
||||
/// Wrapper struct for properly emitting a method declaration.
|
||||
pub struct Method<'a>(pub &'a clean::SelfTy, pub &'a clean::FnDecl);
|
||||
/// Similar to VisSpace, but used for mutability
|
||||
@@ -63,6 +67,12 @@ impl UnsafetySpace {
|
||||
}
|
||||
}
|
||||
|
||||
impl ConstnessSpace {
|
||||
pub fn get(&self) -> ast::Constness {
|
||||
let ConstnessSpace(v) = *self; v
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: fmt::Display> fmt::Display for CommaSep<'a, T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
for (i, item) in self.0.iter().enumerate() {
|
||||
@@ -607,6 +617,15 @@ impl fmt::Display for UnsafetySpace {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ConstnessSpace {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.get() {
|
||||
ast::Constness::Const => write!(f, "const "),
|
||||
ast::Constness::NotConst => Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::Import {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
|
||||
Reference in New Issue
Block a user