Skip to content

Commit

Permalink
Configure proper maximum width for rustfmt
Browse files Browse the repository at this point in the history
* Changes:

- Add .rustfmt.toml.
- Specify max line width at 120 characters.

* Motivation:

100 is a wee bit too small, as evidenced by the changes in formatting.
  • Loading branch information
matthieu-m committed Apr 22, 2023
1 parent 8e6b0f0 commit 9c0bc6b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
1 change: 1 addition & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
max_width = 120
12 changes: 3 additions & 9 deletions src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,7 @@ where
// pre-conditions of `grow`.
// - `new_ptr` is valid for `old_layout.size()` bytes, as `new_layout.size()` is greater than or equal to
// that as per the pre-conditions of `grow`.
unsafe {
ptr::copy_nonoverlapping(current_ptr.as_ptr(), new_ptr.as_ptr(), old_layout.size())
};
unsafe { ptr::copy_nonoverlapping(current_ptr.as_ptr(), new_ptr.as_ptr(), old_layout.size()) };

// Safety:
// - `handle` has been allocated by `self`, as per the pre-conditions of `grow`.
Expand Down Expand Up @@ -266,9 +264,7 @@ where
// - `new_ptr` is valid `new_layout.size()` bytes, as it was allocated with `new_layout`.
// - `current_ptr` is valid for `new_layout.size()` bytes, as it is smaller than or equal to
// `old_layout.size()` as per the pre-conditions of `shrink`.
unsafe {
ptr::copy_nonoverlapping(current_ptr.as_ptr(), new_ptr.as_ptr(), new_layout.size())
};
unsafe { ptr::copy_nonoverlapping(current_ptr.as_ptr(), new_ptr.as_ptr(), new_layout.size()) };

// Safety:
// - `handle` has been allocated by `self`, as per the pre-conditions of `shrink`.
Expand Down Expand Up @@ -311,9 +307,7 @@ where
// pre-conditions of `grow`.
// - `new_ptr` is valid for `old_layout.size()` bytes, as `new_layout.size()` is greater than or equal to
// that as per the pre-conditions of `grow`.
unsafe {
ptr::copy_nonoverlapping(current_ptr.as_ptr(), new_ptr.as_ptr(), old_layout.size())
};
unsafe { ptr::copy_nonoverlapping(current_ptr.as_ptr(), new_ptr.as_ptr(), old_layout.size()) };

// Safety:
// - `handle` has been allocated by `self`, as per the pre-conditions of `grow`.
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#![cfg_attr(not(test), no_std)]
// Features
#![feature(allocator_api)]
#![feature(maybe_uninit_write_slice)]
#![feature(ptr_as_uninit)]
#![feature(ptr_metadata)]
#![feature(slice_ptr_get)]
#![feature(specialization)]
Expand Down
4 changes: 1 addition & 3 deletions src/storage/allocator_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ where
}

fn allocate_zeroed(&self, layout: Layout) -> Result<Self::Handle, AllocError> {
self.0
.allocate_zeroed(layout)
.map(|slice| slice.as_non_null_ptr())
self.0.allocate_zeroed(layout).map(|slice| slice.as_non_null_ptr())
}

unsafe fn grow_zeroed(
Expand Down

0 comments on commit 9c0bc6b

Please sign in to comment.