mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-17 12:47:16 +00:00
Fix multiple Default
implementation caveats
This commit is contained in:
parent
8633893bb9
commit
d6714c4b47
@ -236,6 +236,7 @@ impl UserPreemption {
|
||||
const PREEMPTION_INTERVAL: u32 = 100;
|
||||
|
||||
/// Creates a new instance of `UserPreemption`.
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub const fn new() -> Self {
|
||||
UserPreemption { count: 0 }
|
||||
}
|
||||
|
@ -146,6 +146,12 @@ impl WaitQueue {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for WaitQueue {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
/// A waiter that can put the current thread to sleep until it is woken up by the associated
|
||||
/// [`Waker`].
|
||||
///
|
||||
|
@ -73,6 +73,12 @@ impl TtyDriver {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for TtyDriver {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
fn console_input_callback(mut reader: VmReader) {
|
||||
let tty_driver = get_tty_driver();
|
||||
while reader.remain() > 0 {
|
||||
|
@ -85,3 +85,9 @@ impl<E: Events, F: EventsFilter<E>> Subject<E, F> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Events> Default for Subject<E> {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
@ -198,6 +198,12 @@ impl FileTable {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for FileTable {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for FileTable {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
|
@ -97,3 +97,9 @@ impl Clone for Heap {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Heap {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ use alloc::vec::Vec;
|
||||
/// SlotVec is the variant of Vector.
|
||||
/// It guarantees that the index of one item remains unchanged during adding
|
||||
/// or deleting other items of the vector.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SlotVec<T> {
|
||||
// The slots to store items.
|
||||
slots: Vec<Option<T>>,
|
||||
@ -118,11 +119,8 @@ impl<T> SlotVec<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone> Clone for SlotVec<T> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
slots: self.slots.clone(),
|
||||
num_occupied: self.num_occupied,
|
||||
}
|
||||
impl Default for SlotVec<()> {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user