6 releases

0.3.0 Oct 6, 2023
0.2.0 Aug 2, 2023
0.1.3 Apr 17, 2023
0.1.2 Dec 6, 2021

#470 in Development tools

Download history 13845/week @ 2024-07-20 13527/week @ 2024-07-27 15868/week @ 2024-08-03 14715/week @ 2024-08-10 15537/week @ 2024-08-17 10259/week @ 2024-08-24 9099/week @ 2024-08-31 9901/week @ 2024-09-07 7644/week @ 2024-09-14 7898/week @ 2024-09-21 5708/week @ 2024-09-28 6535/week @ 2024-10-05 7843/week @ 2024-10-12 5824/week @ 2024-10-19 6237/week @ 2024-10-26 7155/week @ 2024-11-02

28,149 downloads per month
Used in 57 crates (2 directly)

MIT/Apache

12KB
127 lines

clang-format-rs

A basic clang-format Rust wrapper.

This allows for formatting a given input using clang-format from the system. By default it uses clang-format binary but this can be changed by setting the CLANG_FORMAT_BINARY environment variable, for example, CLANG_FORMAT_BINARY=clang-format-16

use clang_format::{clang_format_with_style, ClangFormatStyle};

fn main() {
    let input = r#"
        struct Test {
        };
    "#;
    let output = clang_format_with_style(input, ClangFormatStyle::Mozilla);
    assert!(output.is_ok());
    assert_eq!(output.unwrap(), "\nstruct Test\n{};\n");
}

Tests

The test suite can be executed using the tests.sh script.

./tests.sh

Licensing

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.

Dependencies

~265–730KB
~17K SLoC