Fix Rust code style
This commit is contained in:
parent
2d356cd473
commit
d49ff190d9
4 changed files with 123 additions and 95 deletions
1
Makefile
1
Makefile
|
@ -82,6 +82,7 @@ target/debug/libpolytreewm.a:
|
|||
test: $(TEST_EXE)
|
||||
@echo "$(TEST_EXE)" | awk '{ OFS="\n"; $$1=$$1 } 1' | /bin/sh
|
||||
$(CARGO) test
|
||||
$(CARGO) fmt --check
|
||||
|
||||
clean:
|
||||
rm -f $(ALL_OBJ) $(ALL_EXE)
|
||||
|
|
1
rustfmt.toml
Normal file
1
rustfmt.toml
Normal file
|
@ -0,0 +1 @@
|
|||
max_width = 80
|
|
@ -14,50 +14,68 @@ const MIN_SNAP_DISTANCE: c_uint = 1;
|
|||
const MAX_SNAP_DISTANCE: c_uint = 10000;
|
||||
|
||||
pub fn border_width(border_width: c_int) -> c_int {
|
||||
if border_width < MIN_BORDER_WIDTH { return MIN_BORDER_WIDTH }
|
||||
if border_width > MAX_BORDER_WIDTH { return MAX_BORDER_WIDTH }
|
||||
if border_width < MIN_BORDER_WIDTH {
|
||||
return MIN_BORDER_WIDTH;
|
||||
}
|
||||
if border_width > MAX_BORDER_WIDTH {
|
||||
return MAX_BORDER_WIDTH;
|
||||
}
|
||||
border_width
|
||||
}
|
||||
|
||||
pub fn default_clients_in_master(default_clients_in_master: c_int) -> c_int {
|
||||
if default_clients_in_master < MIN_DEFAULT_CLIENTS_IN_MASTER {
|
||||
return MIN_DEFAULT_CLIENTS_IN_MASTER
|
||||
return MIN_DEFAULT_CLIENTS_IN_MASTER;
|
||||
}
|
||||
if default_clients_in_master > MAX_DEFAULT_CLIENTS_IN_MASTER {
|
||||
return MAX_DEFAULT_CLIENTS_IN_MASTER
|
||||
return MAX_DEFAULT_CLIENTS_IN_MASTER;
|
||||
}
|
||||
default_clients_in_master
|
||||
}
|
||||
|
||||
pub fn default_master_area_factor(default_master_area_factor: c_float) -> c_float {
|
||||
pub fn default_master_area_factor(
|
||||
default_master_area_factor: c_float,
|
||||
) -> c_float {
|
||||
master_area_factor(default_master_area_factor)
|
||||
}
|
||||
|
||||
pub fn gap_size(gap_size: c_int) -> c_int {
|
||||
if gap_size < MIN_GAP_SIZE { return MIN_GAP_SIZE }
|
||||
if gap_size > MAX_GAP_SIZE { return MAX_GAP_SIZE }
|
||||
if gap_size < MIN_GAP_SIZE {
|
||||
return MIN_GAP_SIZE;
|
||||
}
|
||||
if gap_size > MAX_GAP_SIZE {
|
||||
return MAX_GAP_SIZE;
|
||||
}
|
||||
gap_size
|
||||
}
|
||||
|
||||
pub fn master_area_factor(master_area_factor: c_float) -> c_float {
|
||||
if master_area_factor < MIN_MASTER_AREA_FACTOR { return MIN_MASTER_AREA_FACTOR }
|
||||
if master_area_factor > MAX_MASTER_AREA_FACTOR { return MAX_MASTER_AREA_FACTOR }
|
||||
if master_area_factor < MIN_MASTER_AREA_FACTOR {
|
||||
return MIN_MASTER_AREA_FACTOR;
|
||||
}
|
||||
if master_area_factor > MAX_MASTER_AREA_FACTOR {
|
||||
return MAX_MASTER_AREA_FACTOR;
|
||||
}
|
||||
master_area_factor
|
||||
}
|
||||
|
||||
pub fn max_clients_in_master(max_clients_in_master: c_int) -> c_int {
|
||||
if max_clients_in_master < MIN_MAX_CLIENTS_IN_MASTER {
|
||||
return MIN_MAX_CLIENTS_IN_MASTER
|
||||
return MIN_MAX_CLIENTS_IN_MASTER;
|
||||
}
|
||||
if max_clients_in_master > MAX_MAX_CLIENTS_IN_MASTER {
|
||||
return MAX_MAX_CLIENTS_IN_MASTER
|
||||
return MAX_MAX_CLIENTS_IN_MASTER;
|
||||
}
|
||||
max_clients_in_master
|
||||
}
|
||||
|
||||
pub fn snap_distance(snap_distance: c_uint) -> c_uint {
|
||||
if snap_distance < MIN_SNAP_DISTANCE { return MIN_SNAP_DISTANCE }
|
||||
if snap_distance > MAX_SNAP_DISTANCE { return MAX_SNAP_DISTANCE }
|
||||
if snap_distance < MIN_SNAP_DISTANCE {
|
||||
return MIN_SNAP_DISTANCE;
|
||||
}
|
||||
if snap_distance > MAX_SNAP_DISTANCE {
|
||||
return MAX_SNAP_DISTANCE;
|
||||
}
|
||||
snap_distance
|
||||
}
|
||||
|
||||
|
|
16
src/lib.rs
16
src/lib.rs
|
@ -8,12 +8,16 @@ extern "C" fn constraints_border_width(border_width: c_int) -> c_int {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn constraints_default_clients_in_master(default_clients_in_master: c_int) -> c_int {
|
||||
extern "C" fn constraints_default_clients_in_master(
|
||||
default_clients_in_master: c_int,
|
||||
) -> c_int {
|
||||
constraints::default_clients_in_master(default_clients_in_master)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn constraints_default_master_area_factor(default_master_area_factor: c_float) -> c_float {
|
||||
extern "C" fn constraints_default_master_area_factor(
|
||||
default_master_area_factor: c_float,
|
||||
) -> c_float {
|
||||
constraints::default_master_area_factor(default_master_area_factor)
|
||||
}
|
||||
|
||||
|
@ -23,12 +27,16 @@ extern "C" fn constraints_gap_size(gap_size: c_int) -> c_int {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn constraints_master_area_factor(master_area_factor: c_float) -> c_float {
|
||||
extern "C" fn constraints_master_area_factor(
|
||||
master_area_factor: c_float,
|
||||
) -> c_float {
|
||||
constraints::master_area_factor(master_area_factor)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn constraints_max_clients_in_master(max_clients_in_master: c_int) -> c_int {
|
||||
extern "C" fn constraints_max_clients_in_master(
|
||||
max_clients_in_master: c_int,
|
||||
) -> c_int {
|
||||
constraints::max_clients_in_master(max_clients_in_master)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue