mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
builtin: make array.ensure_cap/1 public
This commit is contained in:
parent
37e5ead75d
commit
d52bac1301
2 changed files with 5 additions and 5 deletions
|
@ -186,10 +186,10 @@ fn new_array_from_c_array_no_alloc(len int, cap int, elm_size int, c_array voidp
|
|||
return arr
|
||||
}
|
||||
|
||||
// Private function. Increases the `cap` of an array to the
|
||||
// required value by copying the data to a new memory location
|
||||
// (creating a clone) unless `a.cap` is already large enough.
|
||||
fn (mut a array) ensure_cap(required int) {
|
||||
// ensure_cap increases the `cap` of an array to the required value
|
||||
// by copying the data to a new memory location (creating a clone),
|
||||
// unless `a.cap` is already large enough.
|
||||
pub fn (mut a array) ensure_cap(required int) {
|
||||
if required <= a.cap {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ fn test_grow_len() {
|
|||
assert sb.len == 20
|
||||
assert sb.cap == 20
|
||||
|
||||
unsafe { sb.ensure_cap(35) }
|
||||
sb.ensure_cap(35)
|
||||
assert sb.len == 20
|
||||
assert sb.cap == 35
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue