types.cr
types
Bring the Rust [Result Option] types to Crystal
Installation
-
Add the dependency to your
shard.yml:dependencies: types: github: initdc/types.cr -
Run
shards install
Usage
require "types/option"
s = Some[0]
n = None(Int32)[]
r = Ok(Int32, String)[0]
e = Err(Int32, String)["error"]
puts "s: #{s}"
puts "n: #{n}"
puts "r: #{r}"
puts "e: #{e}"
arr = [0, 1, 2]
p arr[0]
p Option.from(arr[0])
p arr[10]?
p Option.from?(arr[10]?)
p Option.from! { arr[10] }
Development
TODO: Write development instructions here
Contributing
- Fork it (https://github.com/initdc/types.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- initdc - creator and maintainer
Repository
types.cr
Owner
Statistic
- 1
- 0
- 0
- 0
- 0
- about 6 hours ago
- December 19, 2025
License
Mozilla Public License 2.0
Links
Synced at
Sun, 21 Dec 2025 14:16:55 GMT
Languages