Skip to content

Commit f2cd453

Browse files
committed
Reorder ByteArray methods
1 parent 455831d commit f2cd453

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/bytearray.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ impl ByteArray
2323
self.bytes.len()
2424
}
2525

26+
pub fn capacity(&self) -> usize
27+
{
28+
self.bytes.capacity()
29+
}
30+
2631
pub fn get(&self, idx: usize) -> u8
2732
{
2833
self.bytes[idx]
@@ -33,6 +38,11 @@ impl ByteArray
3338
self.bytes[idx] = val;
3439
}
3540

41+
pub fn resize(&mut self, new_size: usize)
42+
{
43+
self.bytes.resize(new_size, 0);
44+
}
45+
3646
pub unsafe fn get_slice<T>(&self, idx: usize, num_elems: usize) -> &'static [T]
3747
{
3848
assert!((idx + num_elems) * size_of::<T>() <= self.bytes.len());
@@ -91,11 +101,6 @@ impl ByteArray
91101
let dst_slice = unsafe { self.get_slice_mut::<u8>(dst_idx, num_bytes) };
92102
dst_slice.copy_from_slice(src_slice);
93103
}
94-
95-
pub fn resize(&mut self, new_size: usize)
96-
{
97-
self.bytes.resize(new_size, 0);
98-
}
99104
}
100105

101106
/// Copy image data from a source image into a destination image
@@ -186,6 +191,14 @@ pub fn ba_with_size(actor: &mut Actor, _self: Value, num_bytes: Value) -> Result
186191
Ok(Value::ByteArray(p_ba))
187192
}
188193

194+
pub fn ba_resize(actor: &mut Actor, mut ba: Value, new_size: Value) -> Result<Value, String>
195+
{
196+
let ba = ba.unwrap_ba();
197+
let new_size = new_size.unwrap_usize();
198+
ba.resize(new_size);
199+
Ok(Value::Nil)
200+
}
201+
189202
pub fn ba_fill_u32(actor: &mut Actor, mut ba: Value, idx: Value, num: Value, val: Value) -> Result<Value, String>
190203
{
191204
let ba = ba.unwrap_ba();
@@ -270,14 +283,6 @@ pub fn ba_zero_fill(actor: &mut Actor, mut ba: Value) -> Result<Value, String>
270283
Ok(Value::Nil)
271284
}
272285

273-
pub fn ba_resize(actor: &mut Actor, mut ba: Value, new_size: Value) -> Result<Value, String>
274-
{
275-
let ba = ba.unwrap_ba();
276-
let new_size = new_size.unwrap_usize();
277-
ba.resize(new_size);
278-
Ok(Value::Nil)
279-
}
280-
281286
pub fn ba_blit_bgra32(
282287
actor: &mut Actor,
283288
mut dst: Value,

0 commit comments

Comments
 (0)