pub(crate) fn visit_fn(
        &mut self,
        fk: visit::FnKind<'_>,
        generics: &ast::Generics,
        fd: &ast::FnDecl,
        s: Span,
        defaultness: ast::Defaultness,
        inner_attrs: Option<&[ast::Attribute]>,
    ) {
        let indent = self.block_indent;
        let block;
        let rewrite = match fk {
            visit::FnKind::Fn(_, ident, _, _, Some(ref b)) => {
                block = b;
                self.rewrite_fn_before_block(
                    indent,
                    ident,
                    &FnSig::from_fn_kind(&fk, generics, fd, defaultness),
                    mk_sp(s.lo(), b.span.lo()),
                )
            }
            _ => unreachable!(),
        };

        if let Some((fn_str, fn_brace_style)) = rewrite {
            self.format_missing_with_indent(source!(self, s).lo());

            if let Some(rw) = self.single_line_fn(&fn_str, block, inner_attrs) {
                self.push_str(&rw);
                self.last_pos = s.hi();
                return;
            }

            self.push_str(&fn_str);
            match fn_brace_style {
                FnBraceStyle::SameLine => self.push_str(" "),
                FnBraceStyle::NextLine => {
                    self.push_str(&self.block_indent.to_string_with_newline(self.config))
                }
                _ => unreachable!(),
            }
            self.last_pos = source!(self, block.span).lo();
        } else {
            self.format_missing(source!(self, block.span).lo());
        }

        self.visit_block(block, inner_attrs, true)
    }
// Note that this only gets called for function definitions. Required methods
// on traits do not get handled here.
Note that this only gets called for function definitions. Required methods
on traits do not get handled here.
Note that this only gets called for function definitions . Required methods on traits do not get handled here .
pub(crate) fn visit_fn(
        &mut self,
        fk: visit::FnKind<'_>,
        generics: &ast::Generics,
        fd: &ast::FnDecl,
        s: Span,
        defaultness: ast::Defaultness,
        inner_attrs: Option<&[ast::Attribute]>,
    ) {
        let indent = self.block_indent;
        let block;
        let rewrite = match fk {
            visit::FnKind::Fn(_, ident, _, _, Some(ref b)) => {
                block = b;
                self.rewrite_fn_before_block(
                    indent,
                    ident,
                    &FnSig::from_fn_kind(&fk, generics, fd, defaultness),
                    mk_sp(s.lo(), b.span.lo()),
                )
            }
            _ => unreachable!(),
        };
        if let Some((fn_str, fn_brace_style)) = rewrite {
            self.format_missing_with_indent(source!(self, s).lo());
            if let Some(rw) = self.single_line_fn(&fn_str, block, inner_attrs) {
                self.push_str(&rw);
                self.last_pos = s.hi();
                return;
            }
            self.push_str(&fn_str);
            match fn_brace_style {
                FnBraceStyle::SameLine => self.push_str(" "),
                FnBraceStyle::NextLine => {
                    self.push_str(&self.block_indent.to_string_with_newline(self.config))
                }
                _ => unreachable!(),
            }
            self.last_pos = source!(self, block.span).lo();
        } else {
            self.format_missing(source!(self, block.span).lo());
        }
        self.visit_block(block, inner_attrs, true)
    }
pub ( crate ) fn visit_fn ( & mut self , fk : visit :: FnKind < ' _ > , generics : & ast :: Generics , fd : & ast :: FnDecl , s : Span , defaultness : ast :: Defaultness , inner_attrs : Option < & [ ast :: Attribute ] > , ) { let indent = self . block_indent ; let block ; let rewrite = match fk { visit :: FnKind :: Fn ( _ , ident , _ , _ , Some ( ref b ) ) => { block = b ; self . rewrite_fn_before_block ( indent , ident , & FnSig :: from_fn_kind ( & fk , generics , fd , defaultness ) , mk_sp ( s . lo ( ) , b . span . lo ( ) ) , ) } _ => unreachable ! ( ) , } ; if let Some ( ( fn_str , fn_brace_style ) ) = rewrite { self . format_missing_with_indent ( source ! ( self s ) . lo ( ) ) ; if let Some ( rw ) = self . single_line_fn ( & fn_str , block , inner_attrs ) { self . push_str ( & rw ) ; self . last_pos = s . hi ( ) ; return ; } self . push_str ( & fn_str ) ; match fn_brace_style { FnBraceStyle :: SameLine => self . push_str ( " " ) , FnBraceStyle :: NextLine => { self . push_str ( & self . block_indent . to_string_with_newline ( self . config ) ) } _ => unreachable ! ( ) , } self . last_pos = source ! ( self block span ) . lo ( ) ; } else { self . format_missing ( source ! ( self block span ) . lo ( ) ) ; } self . visit_block ( block , inner_attrs , true ) }
Note that this only gets called for function definitions.
Note that this only gets called for function definitions .
&mut self
fk
visit::FnKind<'_>
generics
&ast::Generics
fd
&ast::FnDecl
s
Span
defaultness
ast::Defaultness
inner_attrs
Option<&[ast::Attribute]>
&mut self
fk
visit::FnKind<'_>
generics
&ast::Generics
fd
&ast::FnDecl
s
Span
defaultness
ast::Defaultness
inner_attrs
Option<&[ast::Attribute]>