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