Skip to content

Commit b6b7db1

Browse files
nyurikdanielrh
authored andcommitted
style: reformat all code with defaults
Steps: * Removed rustfmt.toml because all except tab size there are defaults, and 2 space tab size make it harder to read for most Rust devs. * Reformat all code to follow expected Rust standards: ``` cargo fmt --all cd c cargo fmt --all ```
1 parent c0c3621 commit b6b7db1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+233587
-97547
lines changed

c/src/lib.rs

Lines changed: 73 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
11
#![no_std]
2-
#![cfg_attr(not(feature="std"), feature(lang_items))]
3-
#[cfg(feature="std")]
2+
#![cfg_attr(not(feature = "std"), feature(lang_items))]
3+
#[cfg(feature = "std")]
44
extern crate std;
55

66
pub extern crate brotli;
7-
pub use brotli::*;
87
pub use brotli::ffi::compressor::*;
9-
pub use brotli::ffi::multicompress::*;
108
pub use brotli::ffi::decompressor::*;
9+
pub use brotli::ffi::multicompress::*;
10+
pub use brotli::*;
1111
use core::ptr::null_mut;
12-
#[cfg(feature="std")]
13-
unsafe fn std_only_functions() {
14-
let _ = brotli::ffi::decompressor::CBrotliDecoderDecompress(0, null_mut(), null_mut(), null_mut());
15-
}
16-
#[cfg(not(feature="std"))]
12+
#[cfg(feature = "std")]
1713
unsafe fn std_only_functions() {
14+
let _ =
15+
brotli::ffi::decompressor::CBrotliDecoderDecompress(0, null_mut(), null_mut(), null_mut());
1816
}
17+
#[cfg(not(feature = "std"))]
18+
unsafe fn std_only_functions() {}
1919

2020
#[no_mangle]
21-
pub unsafe extern fn instantiate_functions(must_be_null: *const u8) {
21+
pub unsafe extern "C" fn instantiate_functions(must_be_null: *const u8) {
2222
if !must_be_null.is_null() {
2323
let _ = brotli::ffi::compressor::BrotliEncoderVersion();
2424
let _ = brotli::ffi::decompressor::CBrotliDecoderCreateInstance(None, None, null_mut());
2525
let _ = brotli::ffi::decompressor::CBrotliDecoderSetParameter(null_mut(), brotli::ffi::decompressor::ffi::interface::BrotliDecoderParameter::BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION, 0);
26-
let _ = brotli::ffi::decompressor::CBrotliDecoderDecompressStream(null_mut(), null_mut(), null_mut(), null_mut(), null_mut(), null_mut());
26+
let _ = brotli::ffi::decompressor::CBrotliDecoderDecompressStream(
27+
null_mut(),
28+
null_mut(),
29+
null_mut(),
30+
null_mut(),
31+
null_mut(),
32+
null_mut(),
33+
);
2734
std_only_functions();
2835
let _ = brotli::ffi::decompressor::CBrotliDecoderMallocU8(null_mut(), 0);
2936
let _ = brotli::ffi::decompressor::CBrotliDecoderMallocUsize(null_mut(), 0);
@@ -39,35 +46,78 @@ pub unsafe extern fn instantiate_functions(must_be_null: *const u8) {
3946
let _ = brotli::ffi::decompressor::CBrotliDecoderErrorString(
4047
brotli::ffi::decompressor::ffi::BrotliDecoderErrorCode::BROTLI_DECODER_ERROR_UNREACHABLE);
4148
let _ = BrotliEncoderCreateInstance(None, None, null_mut());
42-
let _ = BrotliEncoderSetParameter(null_mut(), brotli::enc::encode::BrotliEncoderParameter::BROTLI_PARAM_MODE, 0);
49+
let _ = BrotliEncoderSetParameter(
50+
null_mut(),
51+
brotli::enc::encode::BrotliEncoderParameter::BROTLI_PARAM_MODE,
52+
0,
53+
);
4354
let _ = BrotliEncoderDestroyInstance(null_mut());
4455
let _ = BrotliEncoderIsFinished(null_mut());
4556
let _ = BrotliEncoderHasMoreOutput(null_mut());
4657
let _ = BrotliEncoderTakeOutput(null_mut(), null_mut());
4758
let _ = BrotliEncoderMaxCompressedSize(0);
4859
let _ = BrotliEncoderSetCustomDictionary(null_mut(), 0, null_mut());
49-
let _ = BrotliEncoderCompress(0,0,BrotliEncoderMode::BROTLI_MODE_GENERIC, 0, null_mut(), null_mut(), null_mut());
50-
let _ = BrotliEncoderCompressStream(null_mut(), BrotliEncoderOperation::BROTLI_OPERATION_FINISH, null_mut(), null_mut(), null_mut(), null_mut(), null_mut());
60+
let _ = BrotliEncoderCompress(
61+
0,
62+
0,
63+
BrotliEncoderMode::BROTLI_MODE_GENERIC,
64+
0,
65+
null_mut(),
66+
null_mut(),
67+
null_mut(),
68+
);
69+
let _ = BrotliEncoderCompressStream(
70+
null_mut(),
71+
BrotliEncoderOperation::BROTLI_OPERATION_FINISH,
72+
null_mut(),
73+
null_mut(),
74+
null_mut(),
75+
null_mut(),
76+
null_mut(),
77+
);
5178
let _ = BrotliEncoderMallocU8(null_mut(), 0);
5279
let _ = BrotliEncoderFreeU8(null_mut(), null_mut(), 0);
5380
let _ = BrotliEncoderMallocUsize(null_mut(), 0);
5481
let _ = BrotliEncoderFreeUsize(null_mut(), null_mut(), 0);
55-
let _ = BrotliEncoderMaxCompressedSizeMulti(0,0);
56-
let _ = BrotliEncoderCompressMulti(0,null_mut(), null_mut(), 0, null_mut(), null_mut(), null_mut(), 0, None, None, null_mut());
82+
let _ = BrotliEncoderMaxCompressedSizeMulti(0, 0);
83+
let _ = BrotliEncoderCompressMulti(
84+
0,
85+
null_mut(),
86+
null_mut(),
87+
0,
88+
null_mut(),
89+
null_mut(),
90+
null_mut(),
91+
0,
92+
None,
93+
None,
94+
null_mut(),
95+
);
5796
let _ = BrotliEncoderCreateWorkPool(0, None, None, null_mut());
5897
let _ = BrotliEncoderDestroyWorkPool(null_mut());
59-
let _ = BrotliEncoderCompressWorkPool(null_mut(), 0, null_mut(), null_mut(), 0, null_mut(), null_mut(), null_mut(), 0 ,None, None, null_mut());
98+
let _ = BrotliEncoderCompressWorkPool(
99+
null_mut(),
100+
0,
101+
null_mut(),
102+
null_mut(),
103+
0,
104+
null_mut(),
105+
null_mut(),
106+
null_mut(),
107+
0,
108+
None,
109+
None,
110+
null_mut(),
111+
);
60112
}
61113
}
62114

63-
#[cfg(not(feature="std"))]
115+
#[cfg(not(feature = "std"))]
64116
#[panic_handler]
65-
extern fn panic_impl(_: &::core::panic::PanicInfo) -> ! {
117+
extern "C" fn panic_impl(_: &::core::panic::PanicInfo) -> ! {
66118
loop {}
67119
}
68120

69-
#[cfg(not(feature="std"))]
121+
#[cfg(not(feature = "std"))]
70122
#[lang = "eh_personality"]
71-
extern "C" fn eh_personality() {
72-
}
73-
123+
extern "C" fn eh_personality() {}

examples/compress.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
extern crate brotli;
2-
#[cfg(not(feature="std"))]
2+
#[cfg(not(feature = "std"))]
33
fn main() {
44
panic!("For no-stdlib examples please see the tests")
55
}
6-
#[cfg(feature="std")]
6+
#[cfg(feature = "std")]
77
fn main() {
88
use std::io;
99
use std::io::{Read, Write};
1010
let stdout = &mut io::stdout();
1111
{
12-
let mut writer = brotli::CompressorWriter::new(
13-
stdout,
14-
4096,
15-
11,
16-
22);
12+
let mut writer = brotli::CompressorWriter::new(stdout, 4096, 11, 22);
1713
let mut buf = [0u8; 4096];
1814
loop {
1915
match io::stdin().read(&mut buf[..]) {
@@ -37,7 +33,7 @@ fn main() {
3733
}
3834
match writer.write_all(&buf[..size]) {
3935
Err(e) => panic!("{}", e),
40-
Ok(_) => {},
36+
Ok(_) => {}
4137
}
4238
}
4339
}

examples/decompress.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
extern crate brotli;
2-
#[cfg(not(feature="std"))]
2+
#[cfg(not(feature = "std"))]
33
fn main() {
44
panic!("For no-stdlib examples please see the tests")
55
}
6-
#[cfg(feature="std")]
6+
#[cfg(feature = "std")]
77
fn main() {
88
use std::io;
99
let stdin = &mut io::stdin();
1010
{
1111
use std::io::{Read, Write};
1212
let mut reader = brotli::Decompressor::new(
13-
stdin,
14-
4096, // buffer size
13+
stdin, 4096, // buffer size
1514
);
1615
let mut buf = [0u8; 4096];
1716
loop {
@@ -28,10 +27,10 @@ fn main() {
2827
}
2928
match io::stdout().write_all(&buf[..size]) {
3029
Err(e) => panic!("{}", e),
31-
Ok(_) => {},
30+
Ok(_) => {}
3231
}
3332
}
3433
}
3534
}
36-
}
35+
}
3736
}

rustfmt.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)