Expand description
§Corlib
X | Twitch | Youtube | Mastodon | GitHub | GitHub Sponsors
Corlib is a various ideas library.
§Library Contents:
§NonOption
Like an option but not optional.
§RcByPtr and WeakByPtr
Compare and hash Rc and Rc::Weak objects by pointer instead of by value.
§RcDefault and ArcDefault
Default traits for returning reference counted types.
§MovableText
For conveniently moving owned and static strings and string slices around.
§AsStr
A trait with an as_str method.
§Droppers
Structs for calling closures on drop.
§GapFillingCounter
A counter that can recycle “gaps”.
§Getters Setters Callers
Macros for implementing getters, setters and calling methods on regular structs and RefCells.
§HasOne
Sometimes you just want the value 1 (or 1.0).
§Lazy
A struct for lazily initialising objects.
Does not contain its own initialising closure.
§As Any
A trait with a method (as_any) for returning a &dyn Any instance of &self (comes with a handy implementation macro).
§Get Some
Convert Options into certainty.
§Inc Dec Macros
Miss the ++ and – operators?
This module can help sort you out.
§Collections
Collections and collection related objects.
§Events
Events and event related objects. Inspred by .NET events.
§Rfc
Macros and functions that help you work with RefCells.
§Upgrading
Functions that help you deal with upgrading reference counted objects.
§Todo:
- Add more documentation
- Add code examples
- Add more tests
- Add Hashmap and Hashset based event implementations
- 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.
Re-exports§
pub use as_any::*;
Modules§
- The AsAny trait and impl_as_any macro, useful for when you want to convert a reference to &dyn Any.
- Collection related stucts and traits, some of which are inspired by .NET.
- Event structs inspired by .NET events.
- Convert Options into certainty with the get_some declarative macro.
- Trait implenenations for getting the value of one for each numeric type.
- Traits for getting reference counted default objects.
- Macros and functions that help you work with RefCells.
- Functions that help you deal with upgrading reference counted objects.
Macros§
- Takes one or more Option enum objects and returns taken values from those Options, panicing with GET_SOME_ERROR_MESSAGE if any values are not found.
- A macro for implementing the AsAny trait.
- impl_rfc_borrow_call with an an aliased method name.
- 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_mut_call with an an aliased method name.
- 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).
- Subscribe to an event through a RefCell.
- Subscribe and unsubscribe to an event through a RefCell.
- Unsubscribe to an event through a RefCell.
- Decrements an integer by one.
- Decrements a floating point number by one.
- Increments an integer by one.
- Increments a floating point number by one.
- Intended to be used with a std::cell:RefCell that is a field of $this.
- Like rfc_borrow but for situations where it is intended that $this be copied i.e. where $this is already a reference.
- Intended to be used with a std::cell:RefCell that is a field of $this.
- Like rfc_borrow_mut but for situations where it is intended that $this be copied i.e. where $this is already a reference.
Structs§
- Contains a closure and a container reference parameter. The closure is called with the container parameter being passed to it when dropped. The container parameter may refer to a containing object.
- Contains a closure that is called when dropped.
- Increments a number returning “gap” mumbers, numbers that are reported to be no longer “be in use”, first.
- A lazily constructed object that does not contain an initaising function pointer.
- 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.
- Contains a closure and a parameter. The closure is called with the parameter being passed to it when dropped.
- A Container for comparing and hashing reference counted values using their pointers.
- A Container for comparing and hashing weak reference counted values using their pointers.
Enums§
- MovableText: Ideal for when you want to be able to move text around that could either be a String ot a static String slice.
Traits§
- Provides as_str as a trait method.