Crate corlib

Source
Expand description

§Corlib

Crates.io License Downloads Docs Twitch Status

X | Twitch | Youtube | Mastodon | GitHub | GitHub Sponsors

Corlib is a various ideas library.

§Library Contents:

§NonOption

Like an option but not optional.

§Immut

Forces external immutability.

§WorkInProgressResult And IdedWorkInProgressResult

Containers used for communicating the results and statuses of ongoing operations.

§GapFillingCounter

A counter that can recycle “gaps”.

§Getter Setter Caller Macros

Macros for implementing getters, setters and calling methods on regular structs and RefCells.

§Get Some

Convert Options into certainty.

§Sub-Modules:

§Cell

Macros, functions and the RefCellStore which help make working with RefCells easier.

§Collections

Collections and collection related objects.

§Convert

Convert stuff into &dyn Any and &mut dyn Any.

§Drop Panic

A fun way to crash your programme.

§Events

Events and event related objects.

Loosely inspred by .NET events.

§Has One

Get the value of one for each numeric type.

§Inc Dec

Miss the ++ and -- operators?

This module can help sort you out.

§Rc

Reference counting related helper structs and traits.

§Text

Look at SendableText and AsStr.

§Upgrading

Functions that help you deal with upgrading reference counted objects.

§Value

For when you want to move values around.

§Compiler:

Build with the latest stable compiler.

§Todo:

  • Add more documentation
  • Add code examples
  • Add more tests
  • Clean-up the code
  • 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()
{

    bar();

}

Not this:

fn foo()
{
    bar();
}

§License

Licensed under either of:

  • Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0 (see also: https://www.tldrlegal.com/license/apache-license-2-0-apache-2-0))
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT (see also: https://www.tldrlegal.com/license/mit-license))

at your discretion


§Contributing

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.

Modules§

cargo_env
This module mostly contains functions that return cargo environment variables.
cell
The items in this module help you work with RefCells.
collections
Collection related stucts and traits, some of which are inspired by .NET.
convert
Convert stuff into &dyn Any and &mut dyn Anys.
drop_panic
A fun way to crash your programme.
events
Event structs loosely inspired by .NET events.
has_one
Trait implenenations for getting the value of one for each numeric type.
inc_dec
This module enables you to do ++ and – like operations on standard numeric primitives.
rc
Reference counting related helper structs and traits.
text
Do stuff with text.
upgrading
Functions that help you deal with upgrading reference counted objects.
value
For when you want to do stuff with values and generic type constraints.

Macros§

checked_mm_mut
Calls checked_sub on an integer with 1 as a parameter.
checked_pp_mut
Calls checked_add on an integer with 1 as a parameter.
get_some
Takes one or more Option enum objects and returns the taken objects from those Options, panicking with “Error: Nothing here!” if at least one object isn’t found.
impl_aliased_get_mut
impl_aliased_get_mut_2
impl_aliased_get_ref
impl_aliased_get_ref_2
impl_aliased_get_ref_mut_2
impl_as_any_mut
impl_as_any_mut_method
impl_as_any_ref
A macro for implementing the AsAnyRef trait.
impl_as_any_ref_method
impl_cargo_env_accessor
impl_cargo_env_accessor_pair
impl_getDeprecated
impl_get_2Deprecated
impl_get_2_setDeprecated
impl_get_mut
impl_get_mut_2
impl_get_ref
impl_get_ref_2
impl_get_ref_mut_2
impl_get_setDeprecated
impl_get_set_2_ref_mut_2
impl_pub_single_sub_args_event_method
Generates a method that enables convenient access to the result of a pub_this call on a SingleSubArgsEvent.
impl_pub_single_sub_event_method
Generates a method that enables convenient access to the result of a pub_this call on a SingleSubEvent.
impl_rfc_borrow
impl_rfc_borrow_2
impl_rfc_borrow_aliased_call
impl_rfc_borrow_call with an an aliased method name.
impl_rfc_borrow_and_mut_2
impl_rfc_borrow_call
Calls borrow on a RefCelled field and calls a method on the returned Ref. Don’t try to return a reference though (It wont work).
impl_rfc_borrow_get
impl_rfc_borrow_get_2
impl_rfc_borrow_mut
impl_rfc_borrow_mut_2
impl_rfc_borrow_mut_aliased_call
impl_rfc_borrow_mut_call with an an aliased method name.
impl_rfc_borrow_mut_call
Calls borrow_mut on a RefCelled field and calls a method on the returned RefMut. Don’t try to return a reference though (It wont work).
impl_rfc_borrow_mut_get_set_2
impl_rfc_borrow_mut_set
impl_rfc_borrow_mut_set_2
impl_rfc_borrow_mut_subscribe
Subscribe to an event through a RefCell.
impl_rfc_borrow_mut_subscription
Subscribe and unsubscribe to an event through a RefCell.
impl_rfc_borrow_mut_unsubscribe
Unsubscribe to an event through a RefCell.
impl_set
impl_set_2
impl_weak_self_trait
This macro helps you implement the weak-self design pattern.
mm
Decrements the provided integer by one.
mm_mut
Decrements the provided integer by one and returns it.
mmf
Decrements the provided floating point number by one.
mmf_mut
Decrements the provided floating point number by one and returns it.
omm_mut
Calls overflowing_sub on an integer with 1 as a parameter.
opp_mut
Calls overflowing_add on an integer with 1 as a parameter.
pp
Increments the provided integer by one.
pp_mut
Increments the provided integer by one and returns it.
ppf
Increments the provided floating point number by one.
ppf_mut
Increments the provided floating point number by one and returns it.
rfc_borrow
Intended to be used with a std::cell:RefCell that is a field of $this.
rfc_borrow_2
Like rfc_borrow but for situations where it is intended that $this be copied i.e. where $this is already a reference.
rfc_borrow_mut
Intended to be used with a std::cell:RefCell that is a field of $this.
rfc_borrow_mut_2
Like rfc_borrow_mut but for situations where it is intended that $this be copied i.e. where $this is already a reference.
trait_getDeprecated
trait_get_2Deprecated
trait_get_2_setDeprecated
trait_get_mut
trait_get_mut_2
trait_get_ref
trait_get_ref_2
trait_get_ref_2_mut_2
trait_get_setDeprecated
trait_get_set_2_ref_mut_2
trait_get_weak_self_ref
trait_rfc_borrow
trait_rfc_borrow_2
trait_rfc_borrow_and_mut_2
trait_rfc_borrow_mut
trait_rfc_borrow_mut_2
trait_set
wmm_mut
Calls wrapping_sub on an integer with 1 as a parameter.
wpp_mut
Calls wrapping_add on an integer with 1 as a parameter.

Structs§

GapFillingCounter
Increments a number returning “gap” mumbers, numbers that are reported to be no longer “be in use”, first.
IdedWorkInProgressResult
A WorkInProgressResult with an id.
Immut
This object makes its contained object externally immutable only.
NonOption
An Option that is not really optional (but is still kinda). Start by creating the object by calling invalid (probably as a field in a struct constructor) and setting a value by calling “set” with a parameter as soon as possible. Attempting to use an invalid NonOption will cause a panic, so make absolutely sure you’ve set it with a value before calling “get_ref”, “get_mut” etc.
WorkInProgressResult
For indicating when some work has been done or is in the process of being done, potentially being accompanied by a result object.

Traits§

WeakSelf
This trait is useful when implementing the weak-self design pattern.