block2
Apple's C language extension of blocks
0.6.2
88M downloads/mo
#877 most downloaded on crates.io
madsmtm/objc2
What this package is like to depend on
Last release 10 months ago
04 Oct 2025
Ships fairly regularly
a new release about every 4 months
Nearly every release is documented
notes for 9 of 9 stable releases
Nothing withdrawn
no release was ever pulled
5 years old
18 releases · first in 2021
1 release in the last 12 months
see the full history below
Release timeline
18 releases · Nov 2021 to Oct 2025Releases
latest 18-
0.6.204 Oct 2025 -
0.6.119 Apr 2025Release notes
Open source →Added
- Added
DynBlockalias to help facilitate upgrading to v0.7 when that's done.
Fixed
- Slightly improved documentation around
ManualBlockEncoding.
- Added
-
0.6.022 Jan 2025Release notes
Open source →Added
-
Added
StackBlock::with_encodingandRcBlock::with_encodingfor creating blocks with an encoding specified byManualBlockEncoding.This is useful for certain APIs that require blocks to have an encoding.
-
Added
RcBlock::as_ptr. -
Added
RcBlock::into_raw.
Changed
- BREAKING: Updated
objc2dependency tov0.6.0.
Fixed
- BREAKING: Converted function signatures into using
extern "C-unwind". This allows unwinding through blocks.
Removed
- BREAKING: Removed the deprecated
appleCargo feature flag.
-
-
0.5.121 May 2024Release notes
Open source →Deprecated
- Deprecated the
appleCargo feature flag, it is assumed by default on Apple platforms.
- Deprecated the
-
0.5.017 Apr 2024Release notes
Open source →Added
- BREAKING: Added
Block::copyto convert blocks toRcBlock. This replacesStackBlock::copy, but sinceStackBlockimplementsDeref, this will likely work as before. - Added
RcBlock::new(closure)as a more efficient and flexible alternative toStackBlock::new(closure).copy(). - Added
BlockFntrait to describe validdyn Fntypes for blocks.
Changed
-
BREAKING: Changed how blocks specify their parameter and return types. We now use
dyn Fnso that it is more clear what the parameter and return types are. This also allows us to support non-'staticblocks.// Before let block: &Block<(), ()>; let block: &Block<(i32,), i32>; let block: &Block<(i32, u32), (i32, u32)>; // After let block: &Block<dyn Fn()>; let block: &Block<dyn Fn(i32) -> i32>; let block: &Block<dyn Fn(i32, u32) -> (i32, u32)>; // Now possible let block: &Block<dyn Fn() + '_>; // Non-'static block -
BREAKING: Make
Block::callsafe, and instead move the upholding of the safety invariant to the type itself. -
BREAKING: Renamed
RcBlock::new(ptr)toRcBlock::from_raw(ptr). -
BREAKING: Made
RcBlockuse the null-pointer optimization;RcBlock::from_rawandRcBlock::copynow return anOption. -
BREAKING: Only expose the actually public symbols
_Block_copy,_Block_release,_Block_object_assign,_Block_object_dispose,_NSConcreteGlobalBlock,_NSConcreteStackBlockandClassinffimodule. -
BREAKING: Renamed
IntoConcreteBlocktoIntoBlock, moved associated typeOutputto be a generic parameter, and added lifetime parameter.` -
No longer use the
block-syscrate for linking to the blocks runtime. -
Renamed
ConcreteBlocktoStackBlock, and added a lifetime parameter. The old name is deprecated. -
Added
Copyimplementation forStackBlock.
Removed
- BREAKING: Removed
BlockArgumentsin favour ofBlockFn, which describes both the parameter types, as well as the return type.
Fixed
- BREAKING:
StackBlock::newnow requires the closure to beClone. If this is not desired, useRcBlock::newinstead. - Relaxed the
F: Debugbound onStackBlock'sDebugimplementation. - BREAKING: Fixed
GlobalBlocknot having the correct variance. This may break if you were using lifetimes in your parameters, as those are now a bit too restrictive.
- BREAKING: Added
-
0.4.003 Dec 2023 -
0.3.031 Jul 2023Release notes
Open source →Fixed
- Bumped version number to ensure that this crate can be compiled together
with code that depends on pre-releases of
0.2.0.
- Bumped version number to ensure that this crate can be compiled together
with code that depends on pre-releases of
-
0.2.020 Jun 2023 -
0.2.0-alpha.807 Feb 2023 pre-releaseRelease notes
Open source →Changed
- BREAKING: Use traits from
objc2v0.3.0-beta.5instead ofobjc2-encode. - Updated
ffimodule toblock-sys v0.2.0.
- BREAKING: Use traits from
-
0.2.0-alpha.724 Dec 2022 pre-releaseRelease notes
Open source →Changed
- Improve efficiency when a block doesn't need to be destroyed.
- BREAKING: Updated
objc2-encodetov2.0.0-pre.3. - Updated
ffimodule toblock-sys v0.1.0-beta.2.
-
0.2.0-alpha.628 Aug 2022 pre-releaseRelease notes
Open source →Changed
- BREAKING: Updated
objc2-encodetov2.0.0-pre.2. - Updated
ffimodule toblock-sys v0.1.0-beta.1.
Fixed
- BREAKING: Cleaned up
BlockArgumentstrait, it is now sealed and a subtrait ofEncodeArguments. - BREAKING: Cleaned up
IntoConcreteBlocktrait, it is now sealed and the associated output type has been renamed toOutput.
- BREAKING: Updated
-
0.2.0-alpha.519 Jul 2022 pre-releaseRelease notes
Open source →Added
- Implemented
DebugforBlock,ConcreteBlock,RcBlockandGlobalBlock.
Changed
- BREAKING: Updated
objc2-encodetov2.0.0-pre.1. - Updated
ffimodule toblock-sys v0.1.0-beta.0.
- Implemented
-
0.2.0-alpha.413 Jun 2022 pre-releaseRelease notes
Open source →Changed
- BREAKING: Updated
objc2-encodetov2.0.0-pre.0. - BREAKING: Updated
ffimodule toblock-sys v0.0.4. This tweaks the types of a lot of fields and parameters, and makes the apple runtime always be the default.
Removed
- BREAKING: Removed
DerefMutimplementation forConcreteBlock.
- BREAKING: Updated
-
0.2.0-alpha.303 Jan 2022 pre-releaseRelease notes
Open source →Changed
- Changed
global_block!macro to take an optional semicolon at the end. - Improved documentation.
- BREAKING: Updated
ffimodule toblock-sys v0.0.3.
- Changed
-
0.2.0-alpha.222 Dec 2021 pre-releaseRelease notes
Open source →Added
GlobalBlockand correspondingglobal_block!macro, allowing statically creating blocks that don't reference their environment.
Changed
- BREAKING: Updated
ffimodule toblock-sys v0.0.2. This means thatClassis now!UnwindSafe.
-
0.2.0-alpha.122 Nov 2021 pre-releaseRelease notes
Open source →Added
- Proper GNUStep support using
block-sys. See that crate for usage. - Export
block-sysasffimodule.
Removed
- Dependency on
objc_test_utils.
Fixed
ConcreteBlockno longer allocates block descriptors on the heap.- Better unwind safety in
ConcreteBlock::copy.
- Proper GNUStep support using
-
0.2.0-alpha.022 Nov 2021 pre-releaseRelease notes
Open source →Added
- BREAKING: Blocks now require that parameter and return types implement
objc2_encode::Encode. This is a safety measure to prevent creating blocks with invalid parameters. - Blocks now implements
objc2_encode::RefEncode(and as such can be used in Objective-C message sends). - Update to 2018 edition.
Changed
- BREAKING: Forked the project, so it is now available under the name
block2.
Fixed
- Soundness issues with using empty enums over FFI.
- BREAKING: Blocks now require that parameter and return types implement
-
0.1.619 Nov 2021