This is the changelog, summarising changes in each version(some minor changes may be ommited).
Deprecated these functions:
konst::ptr::is_null
konst::ptr::nonnull::new
Soft-removed "mut_refs"
and "nightly_mut_refs"
feature (by hidding it in docs), changed to using "rust_1_83"
feature to enable &mut
-taking const fn
s.
(to avoid breakage, "mut_refs"
still enables items that use &mut
in const by enabling "rust_latest_stable"
)
Changed "rust_latest_stable"
feature to enable "rust_1_83"
feature.
Added konst::manually_drop::take
function
Added these structs to konst::array
:
ArrayBuilder
ArrayConsumer
Fixed accidental inclusion of private macros in docs.
Changed konst::array::from_fn
macro to allow unparenthesized type to the left of the `=>
Added these macros in konst::array
(which require the "rust_1_83"
feature):
map_
from_fn_
Added "rust_1_83"
feature, which enables the "mut_refs"
feature.
Added "destructure"
macro (requires the "rust_1_83"
feature)
Fixed future compatibility warnings
Defined these macros max
, max_by
, max_by_key
, min
, min_by
, and min_by_key
macros.
Re-exported these macros in the konst::cmp
module:
coerce_to_cmp
const_cmp
const_cmp_for
const_eq
const_eq_for
impl_cmp
max
max_by
max_by_key
min
min_by
min_by_key
Now the fold
and foldr
methods in konst::iter::eval
can take closures with type-annotated parameters (e.g: |accum: Bar, element: Qux| {
)
Removed most Copy
restriction of these macros:
konst::array::from_fn
konst::array::map
konst::iter::collect_const
The pattern of the closure passed tokonst::array::map
is still required not to move out of the input array.
Improved konst::array::{from_fn, map}
macros by allowing its closure parameter to take more unparenthesized patterns.
Improved the konst::iter::{collect_const, eval, for_each}
macros by allowing single-parameter closures passed to the macro to annotate the type of the parameter.
Fixed ChunksExact::remainder
's implementation, it used to return the entire uniterated-over slice, when it should only return the part of the slice that the iterator never yields.
Added these items to konst::slice
module:
ArrayChunksRev
structArrayChunks
structRChunksExactRev
structRChunksExact
structRChunksRev
structRChunks
structarray_chunks
functionas_chunks
functionas_rchunks
functionrchunks_exact
functionrchunks
function
Changed type_eq_projection_fn
macro to not use any unsafe
, this may require fixing bounds in your code.
Added typewit = "1.1"
dependency.
Removed konst::docs
module.
Replaced konst::polymorphism::{HasTypeWitness,MakeTypeWitness,TypeWitnessTypeArg,TypeEq}
from the same-named items in typewit
Added reexport of typewit::{self, CallFn, simple_type_witness,TypeFn,type_fn}
in konst::polymorphism
Fixed Parser::parse_direction
's const
-ness by making it a const fn.
Removed konst::array::try_into_array
macro (it's superceeded by the function of the same name)
Removed functions
Removed these functions because the std equivalent is stably const:
konst::maybe_uninit::{as_ptr, assume_init, assume_init_ref}
konst::ptr::{deref, deref_mut}
konst::slice::{first, last, split_first, split_last}
Removed extra from
parameter of:
konst::slice::{bytes_contain, bytes_rcontain, bytes_find, bytes_rfind}
konst::string::{find, contains, rfind, rcontains}
Added these items in konst::polymorphism
:
HasTypeWitness
(trait)MakeTypeWitness
(trait)TypeEq
(struct)TypeWitnessTypeArg
(trait)type_eq_projection_fn
(macro)
Added konst::docs::type_witnesses
documentation module.
Added konst::chr
module, with these items:
Utf8Encoded
encode_utf8
from_u32_unchecked
from_u32
Renamed IntoIterKind
to ConstIntoIter
.
Added Item
and IntoIter
assoc types to ConstIntoIter, and added checks in iterator macros that Item
matches the item's type.
Moved comparison-related from konst::polymorphism
to new konst::cmp
module.
Renamed ConstCmpMarker
to ConstCmp
.
Renamed these marker types:
IsAConstCmpMarker
toIsAConstCmp
IsIntoIterKind
toIsConstIntoIter
IsNonIteratorKind
toIsIntoIterKind
(not to be confused with the previous name for the traitConstIntoIter
trait)
Removed konst::polymorphism::IsArrayKind
Added konst::polymorphism::IsRefKind
Added konst::cmp::ConstCmpUnref
traits.
Moved all Is*Kind
field-less structs to konst::polymorphism::kinds
, made them all 0-variant enums, and reexported the relevant items in konst::cmp
and konst::iter
.
Removed ConstCmp::This
associated type, now it's derived with ConstCmpUnref
.
Added konst::slice::BytesPattern
trait, implemented for char
, [u8]
, [u8; N]
, and str
.
Made the second parameter of konst::slice::bytes_*
functions take a generic BytesPattern
.
Added konst::string::Pattern
trait, implemented for char
and &str
Made string
functions take P: Pattern<'s>
as the pattern argument.
Bumped minimum supported Rust versions to 1.65.0
Added const_panic = "0.2"
depdendency to konst
Made all panicking code use const_panic
to have the same error messages as at runtime (previously use array indexing hack to panic).
Added konst::array::from_fn
macro.
Added konst::iter::{repeat, Repeat}
.
Added iteration over ranges of non-usize integers and char
.
Added konst::iter::Step
trait.
Added konst::ffi::cstr
module.
Reexporting konst::iter::step::Step
in konst::iter
Added these konst::string
items:
Chars
(struct)RChars
(struct)CharIndices
(struct)RCharIndices
(struct)char_indices
(function)chars
(function)from_iter
(macro)is_char_boundary
(function)str_concat
(macro)str_join
(macro)
Rewrote Parser
to only support parsing &str
.
Added Parser::{skip, skip_back}
methods
Removed these parser functions:
Parser::*_b
Parser::*_u8
(except forparse_u8
)Parser::advance_*
Parser::from_bytes
Renamed these Parser
functions:
from_str
tonew
.bytes
toremainder
(and takes&str
)
Added these Parser
methods:
into_other_error
rsplit_terminator
rsplit
split_keep
split_terminator
split
skip
skip_back
trim
trim_matches
with_start_offset
Added ParseError::other_error
function for constructing Other
errors with custom error messages.
Added FromBoth
variant to konst::parser::ParseDirection
Renamed ParserFor
trait to HasParser
Added SplitExhausted
,DelimiterNotFound
variants to konst::parsing::ErrorKind
Removed map_err
capability of try_rebind
due to being untested and unused.
Removed unwrap_opt_or
and unwrap_res_or
macros (they are superceeded by other macros).
Made array::map
and iterator-taking macros support specifying an explicit return type.
Added assertc_eq
, assertc_ne
macros.
Added type annotation support to rebind_if_ok
macro (for the pattern as a whole).
Fixed support for continue
and break
inside of konst::for_range
.
Changed Parser
methods from taking &str
patterns to taking any P: Pattern<'p>
Renamed parse_any
macro to parser_method
Removed konst::primitive::parse_*_b
functions
Renamed "parsing"
feature to "parsing_proc"
and "parsing_no_proc"
feature to "parsing"
Added "iter"
feature(enabled by default), feature-gating all iterator-related items.
Added "debug"
feature for additional safety checks in konst
unsafe code.
Made konst
crate 2021 edition, resolver="2"
.
Removed all "rust_1_*"
features, and all old-version-dependent code.
Renamed konst_macro_rules
to konst_kernel
crate, which defines items for reexporting in konst
(mostly needed for having macros in submodules).
Addeded konst::iter
module, with const encodings of Iterator
API:
konst::iter::collect_const
(macro)konst::iter::eval
(macro)konst::iter::for_each
(macro)konst::iter::into_iter
(macro)konst::iter::iterator_dsl
(documentation module)konst::iter::IntoIterWrapper
(struct)konst::iter::IsIntoIterKind
(struct)konst::iter::IsIteratorKind
(struct)konst::iter::IsNonIteratorKind
(struct)konst::iter::IsStdKind
(struct)konst::iter::IntoIterKind
(trait)
Added these const fn (enabled by the "rust_1_64"
feature):
konst::string::split
konst::string::rsplit
konst::string::split_terminator
konst::string::rsplit_terminator
konst::string::split_once
konst::string::rsplit_once
Added these const string iterators (enabled by the "rust_1_64"
feature):
konst::string::Split
konst::string::RSplit
konst::string::SplitTerminator
konst::string::RSplitTerminator
Added these slice functions:
konst::slice::chunks
(requires the"rust_1_64"
feature)konst::slice::chunks_exact
(requires the"rust_1_64"
feature)konst::slice::iter
konst::slice::iter_copied
(requires the"rust_1_61"
feature)konst::slice::windows
(requires the"rust_1_64"
feature)
Added these slice iterator types:
konst::slice::Chunks
(requires the"rust_1_64"
feature)konst::slice::ChunksRev
(requires the"rust_1_64"
feature)konst::slice::ChunksExact
(requires the"rust_1_64"
feature)konst::slice::ChunksExactRev
(requires the"rust_1_64"
feature)konst::slice::Iter
konst::slice::IterRev
konst::slice::IterCopied
(requires the"rust_1_61"
feature)konst::slice::IterCopiedRev
(requires the"rust_1_61"
feature)konst::slice::Windows
(requires the"rust_1_64"
feature)konst::slice::WindowsRev
(requires the"rust_1_64"
feature)
Added range iterator types:
konst::range::RangeIter
konst::range::RangeIterRev
konst::range::RangeInclusiveIter
konst::range::RangeInclusiveIterRev
konst::range::RangeFromIter
Added konst::option::copied
function (requires the "rust_1_61"
feature)
Added "rust_1_51"
feature, made "const_generics"
feature delegate to it.
Added "rust_1_57"
feature, which enables the "rust_1_56"
feature.
Added "rust_1_61"
feature, which enables the "rust_1_57"
feature.
Changed "rust_1_64"
feature: now it enables "rust_1_61"
feature.
Added "rust_latest_stable"
feature that enables the latest "rust_*"
feature.
Added "rust_1_64"
crate feature, to make slice indexing take constant time from Rust 1.64.0 onwards.
Changed "constant_time_slice"
to enable "rust_1_64"
feature.
Made "deref_raw_in_fn"
feature only require Rust 1.56.0 by stopping the use of an (already stabilized) nightly feature flag.
Added these functions:
konst::manually_drop::as_inner
(requires the"rust_1_56"
feature).konst::manually_drop::as_inner_mut
(requires the"mut_refs"
feature).
Added these MaybeUninit
functions:
konst::maybe_uninit::array_assume_init
(requires the"rust_1_56"
feature)konst::maybe_uninit::as_mut_ptr
(requires the"mut_refs"
feature)konst::maybe_uninit::as_ptr
konst::maybe_uninit::assume_init_mut
(requires the"mut_refs"
feature)konst::maybe_uninit::assume_init_ref
(requires the"rust_1_56"
feature)konst::maybe_uninit::assume_init
(requires the"rust_1_56"
feature)konst::maybe_uninit::uninit_array
(requires the"rust_1_56"
feature)konst::maybe_uninit::write
(requires the"mut_refs"
feature)
Added these raw pointer/NonNull
functins:
konst::ptr::as_mut
(requires the"mut_refs"
feature)konst::ptr::as_ref
(requires the"rust_1_56"
feature)konst::ptr::deref_mut
(requires the"mut_refs"
feature)konst::ptr::deref
(requires the"rust_1_56"
feature)konst::ptr::is_null
(requires the"rust_1_56"
feature)konst::ptr::non_null::as_mut
(requires the"mut_refs"
feature)konst::ptr::non_null::as_ref
(requires the"rust_1_56"
feature)konst::ptr::non_null::from_mut
(requires the"mut_refs"
feature)konst::ptr::non_null::from_ref
konst::ptr::non_null::new
(requires the"rust_1_56"
feature)
Added konst::array::map
, which requires the rust_1_56
feature.
Added "rust_1_55"
and "rust_1_56"
features.
Change: functions that required the "deref_raw_in_fn"
feature can be used on Rust 1.56.0 (whenever that reaches stable) with the "rust_1_56"
feature.
Added these slice functions
konst::slice::bytes_find_keep
konst::slice::bytes_find_skip
konst::slice::bytes_rfind_keep
konst::slice::bytes_rfind_skip
konst::slice::bytes_trim_end_matches
konst::slice::bytes_trim_end
konst::slice::bytes_trim_matches
konst::slice::bytes_trim_start_matches
konst::slice::bytes_trim_start
konst::slice::bytes_trim
konst::slice::get_from_mut
(requires the"mut_refs"
feature)konst::slice::get_from
konst::slice::get_mut
(requires the"mut_refs"
feature)konst::slice::get_range_mut
(requires the"mut_refs"
feature)konst::slice::get_range
konst::slice::get_up_to_mut
(requires the"mut_refs"
feature)konst::slice::get_up_to
konst::slice::get
Added these str functions, all of which require the "rust_1_55"
feature:
konst::string::from_utf8
konst::string::get_from
konst::string::get_range
konst::string::get_up_to
konst::string::split_at
konst::string::str_from
konst::string::str_range
konst::string::strip_prefix
konst::string::strip_suffix
konst::string::str_up_to
konst::string::trim
konst::string::trim_start
konst::string::trim_end
konst::string::trim_matches
konst::string::trim_start_matches
konst::string::trim_end_matches
konst::string::find_skip
konst::string::find_keep
konst::string::rfind_skip
konst::string::rfind_keep
Renamed these functions, reexported with old name, and deprecated the reexport:
string::str_starts_with
: renamed tostring::starts_with
string::str_ends_with
: renamed tostring::ends_with
string::str_find
: renamed tostring::find
string::str_contains
: renamed tostring::contains
string::str_rfind
: renamed tostring::rfind
string::str_rcontains
: renamed tostring::rcontains
Added the konst::string::from_utf8
macro.
Added konst::string::Utf8Error
error struct.
Fixed internal soundness bug in where unions weren't #[repr(C))]
.
Added the "mut_refs"
, "nightly_mut_refs"
features for const fns that take mutable references.
Added these mutable slice functions:
konst::slice::first_mut
konst::slice::last_mut
konst::slice::slice_from_mut
konst::slice::slice_range_mut
konst::slice::slice_up_to_mut
konst::slice::split_at_mut
konst::slice::split_first_mut
konst::slice::split_last_mut
konst::slice::try_into_array_mut
Added ParseFor
trait and parse_with
macro, for type-dispatched parsing.
Added StdParser
struct as the parser for std types.
Broadened valid syntax for try_rebind/rebind_if_ok
Added trailing comma support to every macros, where applicable
Fixed handling of length argument of slice::try_into_array
macro,
when the "const_generics" feature is enabled,
it would previously require non-trivial expressions to be wrapped in braces.
Added the slice::try_into_array
macro and nightly function to try to convert &[T]
to &[T; N]
Defined the slice::TryIntoArrayError
as the error type for slice::try_into_array
Added slice::{first, last, split_first, split_last}
functions, const equivalents of the slice methods.
Added these (generic) constants, which can be used in [CONST; LEN]
even for non-Copy
types:
option::NONE
: alias forNone
alloc_type::COW_STR_NEW
: An emptyCow<'_, str<
alloc_type::COW_SLICE_NEW
: An emptyCow<'_, [T]>
alloc_type::STRING_NEW
: An emptyString
alloc_type::VEC_NEW}
: An emptyVec<T>
maybe_uninit::UNINIT
: An uninitMaybeUninit<T>
maybe_uninit::UNINIT_ARRAY
: An uninit[MaybeUninit<T>; LEN]
Added "deref_raw_in_fn"
feature to enable const fn
s that need to dereference raw pointers, requires the nightly compiler.
Added "alloc"
feature to enable the alloc_type
module.
Defined the konst_macro_rules
crate 0.2.0, to reexport macros in konst
submodules.
Added macro equivalents of Option::{and_then, filter, map, ok_or, ok_or_else, or_else, unwrap_or, unwrap_or_else, flatten}
in the konst::option
module.
Added macro equivalents of Result::{unwrap_ctx, unwrap_or, unwrap_or_else, ok, err, map, map_err, and_then, or_else}
in the konst::result
module.
Deprecated the unwrap_opt_or
, and unwrap_res_or
macros.
Defined result::unwrap_err_or_else
macro for convenience.
Added try_
and try_opt
macros
Added primitive::parse_*
functions, to parse all integer types and bool from &str
or &[u8]
.
Added Parser::parse_
methods for the remaining integer types (u8
, u16
, u32
, i8
, i16
, i32
)
Added "parsing_no_proc" cargo feature, to enable all parser items except for those that require using the konst_proc_macro
crate.
Fixed eq_bytes
and cmp_bytes
doc examples
Fixed the lack of indicators that the rebind_if_ok
and try_rebind
macros require the "parsing_no_proc"
feature.
Breaking change: tightened the syntax of the parse_any
macro, now it requires the last branch in the match-like syntax to be _ => <expression>
, forbidding _
patterns in other branches.
Added support for these Parser
methods in parse_any
:
find_skip
-rfind_skip
-trim_start_matches
-trim_end_matches
Moved these functions from slice::cmp
to slice
, and reexported back in slice::cmp
:
cmp_slice_u8
: renamed tocmp_bytes
eq_slice_u8
: renamed toeq_bytes
cmp_option_slice_u8
: renamed tocmp_option_bytes
eq_option_slice_u8
: renamed toeq_option_bytes
The above*_bytes
functions do not require any cargo features to use.
Added comparison functions for &[usize]
, &[isize]
, Option<&[usize]>
, Option<&[isize]>
Defined the konst_proc_macros
crate 0.1.0, for internal use by konst
.
Defined equality and ordering comparison functions for:
-
All the primitive types, including integers, bool, char, and
Option
s of them, inside theprimitives::cmp
module. -
Range
s andRangeInclusive
s of all unsigned integer types, inside therange::cmp
module. -
All the
NonZero*
types, andOption<NonZero*>
types, inside thenonzero::cmp
module. -
&str
andOption<&str>
, inside thestring
module. -
Ordering
,Option<Ordering>
,PhantomData<T>
,PhantomPinned
, inside theother::cmp
module. -
Slices of integers,
&[bool]
,&[char]
,&[&str]
,&[&[u8]]
, andOption
s of them, inside theslice::cmp
module.
Defined the polymorphism module, to do type-based overloading, currently limited to const_eq
and const_cmp
methods.
Defined these items in the polymorphism
module:
-
CmpWrapper
: Wrapper type which implements many methods for std types, currently onlyconst_eq
andconst_cmp
. -
ConstCmpMarker: Trait for describing whether a type is from the standard library, and has
const_eq
and/orconst_cmp
methods. -
IsAConstCmpMarker
: Helper type used to automatically coerce standard library types into CmpWrapper, and leaving non-std ones unwrapped. -
IsArrayKind
,IsNotStdKind
,IsStdKind
: for describing the kind of type something is.
Declared these functions in the slice
module:
bytes_contain
, bytes_end_with
, bytes_find
, bytes_rcontain
, bytes_rfind
, bytes_start_with
, bytes_strip_prefix
, bytes_strip_suffix
, slice_from
, slice_range
, slice_up_to
, split_at
.
Declared these functions in the string
module:
str_contains
, str_ends_with
, str_find
, str_rcontains
, str_rfind
, str_starts_with
Declared the parsing
module with:
-
Parser
: A parser constructible from&[u8]
or&str
. -
ParseError
: The error type returned by fallibleParser
methods. -
ErrorKind
: Enum for the kinds of parsing errors that happened, included insideParseError
-
ParseDirection
: Enum for the direction a parser is currently parsing from, either the end or the start. -
ParseValueResult
: Type alias for theResult
types thatParser
returns when parsing types. -
ParserResult
: Type alias forResult<'a, Parser, ParseError>
Reexporting these types in the root module:
parsing::{Parser}
string::{cmp_str, eq_str, cmp_option_str, eq_option_str},
Declared these macros:
-
coerce_to_cmp
: For coercing values to types withconst_eq
orconst_cmp
methods. -
const_cmp
,const_cmp_for
,const_eq
,const_eq_for
: for comparing values -
for_range
: for iterating over a range. -
impl_cmp
: For implementingConstCmpMarker
for multiple types, and declaringconst_eq
/const_cmp
. -
konst
: For emulating inline const (const{ }
). -
parse_any
: For callingParser
methods with multiple alternative string literal patterns. -
rebind_if_ok
:if let Ok
which rebinds variables instead of shadowing them. -
try_equal
: For returning early when an ordering isn'tOrdering::Equal
-
try_rebind
: For returning early onErr
, rebinding variables onOk
. -
unwrap_ctx
: Unwraps aResult
, calling.panic()
on the error value on error. -
unwrap_opt_or
: Const-equivalent ofOption::unwrap_or
andOption::unwrap_or_else
. -
unwrap_res_or
: Const-equivalent ofResult::unwrap_or
andResult::unwrap_or_else
.
Defined these cargo features:
-
"cmp"
(enabled by default): Enables all the comparison functions and macros. -
"parsing"
(enabled by default): Enables theparsing
module, macros, and compiles thekonst_proc_macros
crate. -
"constant_time_slice"
: Improves the performance of certain slice functions from taking linear time to constant time. Requires Rust nightly. -
"const_generics"
: Enables impls that use const generics, instead of being implemented for small arrays. Requires Rust 1.51.0 .