3 releases

0.1.2 Dec 6, 2021
0.1.1 Dec 6, 2021
0.1.0 Dec 3, 2021

#1060 in Development tools

Download history 1198/week @ 2022-07-31 1030/week @ 2022-08-07 211/week @ 2022-08-14 1363/week @ 2022-08-21 554/week @ 2022-08-28 161/week @ 2022-09-04 1040/week @ 2022-09-11 63/week @ 2022-09-18 1286/week @ 2022-09-25 368/week @ 2022-10-02 361/week @ 2022-10-09 461/week @ 2022-10-16 628/week @ 2022-10-23 420/week @ 2022-10-30 266/week @ 2022-11-06 468/week @ 2022-11-13

1,789 downloads per month
Used in 3 crates (via cxx-qt-gen)


95 lines


A basic clang-format Rust wrapper.

This allows for formatting a given input using clang-format from the system.

use clang_format::{clang_format, ClangFormatStyle, CLANG_FORMAT_STYLE};

fn main() {

    let input = r#"
        struct Test {

    let output = clang_format(input);
    assert_eq!(output.unwrap(), "\nstruct Test\n{};\n");


cargo test --all-targets --all-features --manifest-path Cargo.toml
cargo test --doc --manifest-path Cargo.toml
cargo clippy --all-targets --all-features --manifest-path Cargo.toml -- -D warnings
cargo fmt --manifest-path Cargo.toml -- --check
reuse lint


clang-format-rs is Copyright (C) 2021, Klarälvdalens Datakonsult AB, and is available under the terms of the MIT or the Apache-2.0 licenses.

Contact KDAB at info@kdab.com to inquire about additional features or services related to this project.

About KDAB

clang-format-rs is supported and maintained by Klarälvdalens Datakonsult AB (KDAB).

The KDAB Group is the global No.1 software consultancy for Qt, C++ and OpenGL applications across desktop, embedded and mobile platforms.

The KDAB Group provides consulting and mentoring for developing Qt applications from scratch and in porting from all popular and legacy frameworks to Qt. We continue to help develop parts of Qt and are one of the major contributors to the Qt Project. We can give advanced or standard trainings anywhere around the globe on Qt as well as C++, OpenGL, 3D and more.

Please visit https://www.kdab.com to meet the people who write code like this.