Skip to content

Unable to format include! files #3619

Open
@JP-Ellis

Description

@JP-Ellis

I have a use-case in which I have sometimes very large mathematical expressions which, for the sake of code clarity, are contained in a separate file and included into the code with the include! macro.

It would be nice if rustfmt could format these included files as well. Currently it is unable to do so as they are not valid rust code on their own.

A very simple example would be:

func.inc.rs

(((8.11757) + ((x) * ((4.49504) + ((x) * ((5.99194) + ((x) * ((6.65951) + ((x) * ((6.32449) + ((x) * ((9.07255) + ((x) * ((9.9719) + ((x) * ((2.7438) + ((x) * ((7.59082) + ((4.21836) * (x))))))))))))))))))).powi(-1)) * ((5.78209) + ((x) * ((4.60331) + ((x) * ((1.60796) + ((x) * ((1.5818) + ((x) * ((5.72673) + ((x) * ((0.879603) + ((x) * ((2.03822) + ((x) * ((5.84432) + ((x) * ((7.51743) + ((5.4175) * (x)))))))))))))))))))

main.rs

fn main() {
   let f = |x| include!("func.inc.rs");
   // Do something with f
}

Is there any way that rustfmt could format func.inc.rs? Or could this be implemented in the future?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions