module
Pf::Kit
Overview
Auxiliary data structures.
Direct including types
Defined in:
permafrost.crpermafrost/kit.cr
permafrost/kit/hybrid_array.cr
permafrost/kit/node.cr
permafrost/kit/sparse32.cr
permafrost/kit/uint96.cr
Constant Summary
-
AUTHOR_FIRST =
AUTHOR_NONE + 1 -
AUTHOR_NONE =
AuthorId.new(0)
Macro Summary
-
stack_alloc(call)
Stack allocation using the experimental
ReferenceStorageAPI. -
stack_array(type, stackcap = 16)
Allocates a
HybridArraywhose main buffer is located on the stack and has the given capacity stackcap.
Macro Detail
macro stack_alloc(call)
#
Stack allocation using the experimental ReferenceStorage API.
Reference: https://github.com/crystal-lang/crystal/issues/13481#issuecomment-2603298285
See also in general: https://github.com/crystal-lang/crystal/issues/13481
class Foo
def initialize(@a : UInt64, @b : UInt64)
end
end
foo = Pf::Kit.stack_alloc Foo.new(100u64, 200u64)
pp foo
macro stack_array(type, stackcap = 16)
#
Allocates a HybridArray whose main buffer is located on the stack and
has the given capacity stackcap.
ary = Pf::Kit.stack_array(Int32, 16)
ary << 100
ary << 200
ary << 300
pp ary # => HybridArray{100, 200, 300}
WARNING the lifetime of the returned array is equal to the lifetime of the function/method you call this in. Do not use this in e.g. initialize: it's going to be the lifetime of the call to initialize, not the instance's lifetime.