• 20th Jul 2023
  • 3 min read


Corlib is a general purpose library.

Contents at a glance:


Like an option but not optional.


Compare and hash an Rc by pointer instead of value.

RcDefault and ArcDefault

Default trats for returning reference counted types.

Text Enums

All String types unified into various enum types.


RcByPtr, but weak.


Structs for caling closures on drop.


A counter that can recycle "gaps".

Get Rc Or Weak Self

Traits and macros to support the Weak-Self pattern.

Get Ref Mut

Traits for getting references.

Getters Setters Callers

Macroes for implementing getters, setters and calling stuff.


Sometimes you just want the value 1 (or 1.0).


A trait for implenting a method that returns an invalid instance of Self.


A struct for lazily initalising objects. Dos not contain its own initalising closure.


Collection and collection related objects.


Events and events related objects, inspred by .net events.

The Weak-Self Pattern

When a reference counted object holds a weak reference to itself, which can be accessed publicly, this can be called the Weak-Self pattern.

This is useful when your types need to be used with Rc<Any> and you want to get a reference counted instance once the exact type of the Any instance has been established.

If an object stores a weak (or strong) refernce to its reference counted instance, this makes it a reference type.

A referece type is a type that can only be refenced and not directly accessed or manipulated.


  • Add more documentation
  • Add code examples
  • Add some tests
  • Add Hashmap and Hashset based event implementations
  • Code cleanup
  • Solidify the API for 1.0

Coding Style

This project uses a coding style the emphasises the use of white space over keeping the line and column counts as low as possible.

So this:

fn foo()



Not this:

fn foo()


Licensed under either of:

  • Apache License, Version 2.0, (LICENSE-APACHE or (see also:
  • MIT license (LICENSE-MIT or (see also:

at your discretion


Please clone the repository and create an issue explaining what feature or features you'd like to add or bug or bugs you'd like to fix and perhaps how you intend to implement these additions or fixes. Try to include details though it doesn't need to be exhaustive and we'll take it from there (dependant on availability).

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.