move where the modifier is
This commit is contained in:
parent
5a849a87c7
commit
664625402f
10 changed files with 34 additions and 34 deletions
|
@ -79,7 +79,7 @@ wrap_functions!(associate Bitmap;
|
|||
|
||||
wrap_methods!(Bitmap;
|
||||
/// Consumes the Bitmap and returns the contained BitVec.
|
||||
move fn into_bitvec(bitmap) -> NonNull<DisplayBitVec> {
|
||||
fn into_bitvec(move bitmap) -> NonNull<DisplayBitVec> {
|
||||
heap_move_nonnull(bitmap.into())
|
||||
};
|
||||
|
||||
|
@ -88,7 +88,7 @@ wrap_methods!(Bitmap;
|
|||
/// The provided [Bitmap] gets consumed.
|
||||
///
|
||||
/// Returns NULL in case of an error.
|
||||
move fn try_into_packet(bitmap, x: usize, y: usize, compression: CompressionCode) -> *mut Packet {
|
||||
fn try_into_packet(move bitmap, x: usize, y: usize, compression: CompressionCode) -> *mut Packet {
|
||||
heap_move_ok(Packet::try_from(BitmapCommand {
|
||||
bitmap,
|
||||
origin: Origin::new(x, y),
|
||||
|
@ -99,7 +99,7 @@ wrap_methods!(Bitmap;
|
|||
/// Gets an unsafe reference to the data of the [Bitmap] instance.
|
||||
///
|
||||
/// The returned memory is valid for the lifetime of the bitmap.
|
||||
mut fn data_ref_mut(instance) -> ByteSlice {
|
||||
fn data_ref_mut(mut instance) -> ByteSlice {
|
||||
unsafe { ByteSlice::from_slice(instance.data_ref_mut()) }
|
||||
};
|
||||
);
|
||||
|
|
|
@ -43,8 +43,8 @@ wrap_methods!(DisplayBitVec;
|
|||
/// The provided [DisplayBitVec] gets consumed.
|
||||
///
|
||||
/// Returns NULL in case of an error.
|
||||
move fn try_into_packet(
|
||||
bitvec,
|
||||
fn try_into_packet(
|
||||
move bitvec,
|
||||
offset: usize,
|
||||
operation: BinaryOperation,
|
||||
compression: CompressionCode
|
||||
|
@ -69,7 +69,7 @@ wrap_methods!(DisplayBitVec;
|
|||
/// # Panics
|
||||
///
|
||||
/// - when accessing `index` out of bounds
|
||||
ref fn get(instance, index: usize) -> bool {
|
||||
fn get(ref instance, index: usize) -> bool {
|
||||
instance.get(index).map(|x| *x).unwrap_or(false)
|
||||
};
|
||||
|
||||
|
@ -83,25 +83,25 @@ wrap_methods!(DisplayBitVec;
|
|||
/// # Panics
|
||||
///
|
||||
/// - when accessing `index` out of bounds
|
||||
mut fn set(instance, index: usize, value: bool);
|
||||
fn set(mut instance, index: usize, value: bool);
|
||||
|
||||
/// Sets the value of all bits.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// - `value`: the value to set all bits to
|
||||
mut fn fill(instance, value: bool);
|
||||
fn fill(mut instance, value: bool);
|
||||
|
||||
/// Gets the length in bits.
|
||||
ref fn len(instance) -> usize;
|
||||
fn len(ref instance) -> usize;
|
||||
|
||||
/// Returns true if length is 0.
|
||||
ref fn is_empty(instance) -> bool;
|
||||
fn is_empty(ref instance) -> bool;
|
||||
|
||||
/// Gets an unsafe reference to the data of the [DisplayBitVec] instance.
|
||||
///
|
||||
/// The returned memory is valid for the lifetime of the bitvec.
|
||||
mut fn as_raw_mut_slice(instance) -> ByteSlice {
|
||||
fn as_raw_mut_slice(mut instance) -> ByteSlice {
|
||||
unsafe { ByteSlice::from_slice(instance.as_raw_mut_slice()) }
|
||||
};
|
||||
);
|
||||
|
|
|
@ -62,7 +62,7 @@ wrap_methods!(BrightnessGrid;
|
|||
/// The provided [BrightnessGrid] gets consumed.
|
||||
///
|
||||
/// Returns NULL in case of an error.
|
||||
move fn try_into_packet(grid, x: usize, y: usize) -> *mut Packet {
|
||||
fn try_into_packet(move grid, x: usize, y: usize) -> *mut Packet {
|
||||
heap_move_ok(Packet::try_from(BrightnessGridCommand {
|
||||
grid,
|
||||
origin: Origin::new(x, y),
|
||||
|
@ -72,7 +72,7 @@ wrap_methods!(BrightnessGrid;
|
|||
/// Gets an unsafe reference to the data of the instance.
|
||||
///
|
||||
/// The returned memory is valid for the lifetime of the grid.
|
||||
mut fn data_ref_mut(instance) -> ByteSlice {
|
||||
fn data_ref_mut(mut instance) -> ByteSlice {
|
||||
//noinspection RsAssertEqual
|
||||
const _: () = assert!(size_of::<Brightness>() == 1);
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ wrap_methods!(CharGrid;
|
|||
/// # Panics
|
||||
///
|
||||
/// - when accessing `x` or `y` out of bounds
|
||||
ref fn get(instance, x: usize, y: usize) -> u32 {
|
||||
fn get(ref instance, x: usize, y: usize) -> u32 {
|
||||
instance.get(x, y) as u32
|
||||
};
|
||||
|
||||
|
@ -66,7 +66,7 @@ wrap_methods!(CharGrid;
|
|||
///
|
||||
/// - when accessing `x` or `y` out of bounds
|
||||
/// - when providing values that cannot be converted to Rust's `char`.
|
||||
mut fn set(instance, x: usize, y: usize, value: u32) {
|
||||
fn set(mut instance, x: usize, y: usize, value: u32) {
|
||||
instance.set(x, y, char::from_u32(value).unwrap())
|
||||
};
|
||||
|
||||
|
@ -76,7 +76,7 @@ wrap_methods!(CharGrid;
|
|||
///
|
||||
/// - `value`: the value to set all cells to
|
||||
/// - when providing values that cannot be converted to Rust's `char`.
|
||||
mut fn fill(instance, value: u32) {
|
||||
fn fill(mut instance, value: u32) {
|
||||
instance.fill(char::from_u32(value).unwrap())
|
||||
};
|
||||
|
||||
|
@ -85,7 +85,7 @@ wrap_methods!(CharGrid;
|
|||
/// The provided [CharGrid] gets consumed.
|
||||
///
|
||||
/// Returns NULL in case of an error.
|
||||
move fn try_into_packet(grid, x: usize, y: usize) -> *mut Packet {
|
||||
fn try_into_packet(move grid, x: usize, y: usize) -> *mut Packet {
|
||||
heap_move_ok(Packet::try_from(CharGridCommand {
|
||||
grid,
|
||||
origin: Origin::new(x, y),
|
||||
|
|
|
@ -31,7 +31,7 @@ wrap_methods!(Cp437Grid;
|
|||
/// The provided [Cp437Grid] gets consumed.
|
||||
///
|
||||
/// Returns NULL in case of an error.
|
||||
move fn try_into_packet(grid, x: usize, y: usize) -> *mut Packet {
|
||||
fn try_into_packet(move grid, x: usize, y: usize) -> *mut Packet {
|
||||
heap_move_ok(Packet::try_from(Cp437GridCommand {
|
||||
grid,
|
||||
origin: Origin::new(x, y),
|
||||
|
@ -41,7 +41,7 @@ wrap_methods!(Cp437Grid;
|
|||
/// Gets an unsafe reference to the data of the grid.
|
||||
///
|
||||
/// The returned memory is valid for the lifetime of the instance.
|
||||
mut fn data_ref_mut(instance) -> ByteSlice {
|
||||
fn data_ref_mut(mut instance) -> ByteSlice {
|
||||
unsafe { ByteSlice::from_slice(instance.data_ref_mut()) }
|
||||
};
|
||||
);
|
||||
|
|
|
@ -23,10 +23,10 @@ macro_rules! derive_get_width_height {
|
|||
($object_type:ident) => {
|
||||
$crate::macros::wrap_methods! {$object_type;
|
||||
/// Gets the width.
|
||||
ref fn width(instance) -> usize;
|
||||
fn width(ref instance) -> usize;
|
||||
|
||||
/// Gets the height.
|
||||
ref fn height(instance) -> usize;
|
||||
fn height(ref instance) -> usize;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ macro_rules! wrap_grid {
|
|||
/// # Panics
|
||||
///
|
||||
/// - when accessing `x` or `y` out of bounds
|
||||
ref fn get(instance, x: usize, y: usize) -> $value_type;
|
||||
fn get(ref instance, x: usize, y: usize) -> $value_type;
|
||||
|
||||
/// Sets the value of the specified position.
|
||||
///
|
||||
|
@ -57,14 +57,14 @@ macro_rules! wrap_grid {
|
|||
/// # Panics
|
||||
///
|
||||
/// - when accessing `x` or `y` out of bounds
|
||||
mut fn set(instance, x: usize, y: usize, value: $value_type);
|
||||
fn set(mut instance, x: usize, y: usize, value: $value_type);
|
||||
|
||||
/// Sets the state of all cells in the grid.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// - `value`: the value to set all cells to
|
||||
mut fn fill(instance, value: $value_type);
|
||||
fn fill(mut instance, value: $value_type);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue