10 Commits

Author SHA1 Message Date
Ryotaro "Justin" Kimura
50b36e84fa
std: fix BoundedArray test checking wrong condition (#12372) 2022-08-08 18:13:35 -04:00
Andrew Lee
9b82e7f558 std/bounded_array.zig: Add Writer interface 2022-04-14 02:56:40 -04:00
Motiejus Jakštys
65943010c7
std.BoundedArray: return explicit errors (#11044)
* std.BoundedArray: return explicit errors

Makes it easier to mark explicit errors when using BoundedArray
downstream.

* std.BoundedArray.insert() returns Overflow only
2022-03-03 19:39:45 +01:00
Jimmi Holst Christensen
f19b5ecf4b Slice function of BoundedArray now returns slice based on self pointer
If self pointer is const, the slice is const. Otherwise the slice is
mutable.
2022-01-16 01:37:37 -05:00
Jimmi Holst Christensen
a5ac138ae2 Allow BoundArray to be default initialized 2022-01-12 13:17:01 -05:00
Arnav Singh
09f70bdd91
std.bounded_array: support inserting a new value at the end (#10340)
Since `BoundedArray.insert` internally reserves space for the element
to be inserted, it can support inserting at the position that is
the current length of the array. Change the check for the insertion position
to allow this.
2021-12-15 20:10:34 +01:00
Rohlem
a83fb9289f std.bounded_array: fix self parameter type in constSlice
Because `.buffer` is an inline array field, we actually require `self` to be passed as a pointer.
If the compiler decided to pass the object by copying, we would return a pointer to to-be-destroyed stack memory.
2021-11-20 02:35:36 -05:00
Gregory Anders
b26b72f540 BoundedArray: add appendAssumeCapacity 2021-11-14 22:52:01 -05:00
Andrew Kelley
d29871977f remove redundant license headers from zig standard library
We already have a LICENSE file that covers the Zig Standard Library. We
no longer need to remind everyone that the license is MIT in every single
file.

Previously this was introduced to clarify the situation for a fork of
Zig that made Zig's LICENSE file harder to find, and replaced it with
their own license that required annual payments to their company.
However that fork now appears to be dead. So there is no need to
reinforce the copyright notice in every single file.
2021-08-24 12:25:09 -07:00
Frank Denis
8a37fe2176
BoundedArray: a simple way to represent small data whose max size is known (#9134)
This is a simple structure containing an array and a length, that can be viewed as a slice.

It is useful to pass-by-copy small data whose exact size is known at runtime, but whose maximum size is known at comptime. This greatly simplifies code that otherwise would require an allocator, or reimplementing what this type does.
2021-08-24 13:59:28 +02:00