All Projects → prewk → option

prewk / option

Licence: other
Option object for PHP inspired by Rust

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to option

Hackerrank
This repo contain all the problems of hackerrank
Stars: ✭ 40 (+48.15%)
Mutual labels:  datastructures
AlgorithmSet
LeetCode 算法练习集合 ~ 每天一道算法题
Stars: ✭ 19 (-29.63%)
Mutual labels:  datastructures
Julia
Algorithms implemented in the Julia programming language. We're collaborating with the Humans of Julia community!
Stars: ✭ 216 (+700%)
Mutual labels:  datastructures
icpc
Resources for Competitive Programming
Stars: ✭ 14 (-48.15%)
Mutual labels:  datastructures
peds
Type safe persistent/immutable data structures for Go
Stars: ✭ 57 (+111.11%)
Mutual labels:  datastructures
Python Scripts
It contains all the Python Programs, whether it's a GUI, basic, Data Structures, etc. It's a collection of some great Python scripts from basic to advance levels for automating some monotonous tasks.
Stars: ✭ 23 (-14.81%)
Mutual labels:  datastructures
Differentia.js
No longer being supported or maintained. A Graph Theory & Data Structure Library for JavaScript.
Stars: ✭ 13 (-51.85%)
Mutual labels:  datastructures
kwstruct
Struct with keyword arguments support
Stars: ✭ 17 (-37.04%)
Mutual labels:  datastructures
Algorithms
Data Structures & Algorithms. Includes solutions for Cracking the Coding Interview 6th Edition
Stars: ✭ 89 (+229.63%)
Mutual labels:  datastructures
bloomfilter
Simplistic (but fast) java implementation of a bloom filter.
Stars: ✭ 35 (+29.63%)
Mutual labels:  datastructures
treebitmap
Fast IP lookup table for IPv4/IPv6 prefixes
Stars: ✭ 81 (+200%)
Mutual labels:  datastructures
Programacion-Competitiva
Material de programación competitiva elaborado por el Grupo de Programación Competitiva UNI (GPC-UNI)
Stars: ✭ 23 (-14.81%)
Mutual labels:  datastructures
borax
📓 Python3工具集合库——中国农历/中文数字/设计模式/树形结构
Stars: ✭ 57 (+111.11%)
Mutual labels:  datastructures
Problem-Solving
contains all coding interview practice problems, data structures and algorithms implementations. 👨‍💻👨‍💻💥 🚩
Stars: ✭ 14 (-48.15%)
Mutual labels:  datastructures
TUMGAD
Exercise generator and helpful materials for the Introduction to Algorithms and Data Structures 📚
Stars: ✭ 27 (+0%)
Mutual labels:  datastructures
Data-Structures-And-Algorithms
Important data structure and algorithms codes and concept's open-source repository.
Stars: ✭ 48 (+77.78%)
Mutual labels:  datastructures
Joy-of-Computing-using-Python-NPTEL
Joy of computing using Python NPTEL Course Assignment Solutions
Stars: ✭ 22 (-18.52%)
Mutual labels:  datastructures
FPL
Fortran Parameter List. A fortran dictionary where to put the parameters of your application.
Stars: ✭ 29 (+7.41%)
Mutual labels:  datastructures
RedQuarkTutorials
Code used in all my tutorials on my website - redquark.org
Stars: ✭ 27 (+0%)
Mutual labels:  datastructures
datastructures-and-algorithms
Repository for studying/practicing Data Structures, Algorithms and Code Interview Problems.
Stars: ✭ 30 (+11.11%)
Mutual labels:  datastructures

PHP Option Object Build Status Coverage Status

A PHP implementation of Rust's Option type with roughly the same API.

Version information

Version 3.x.x requires PHP 7.3+. Make sure you match the versions for this and the Result library if you use both.

Installation

composer require prewk/option

Usage

use Prewk\Option;
use Prewk\Option\{Some, None};

function findSomething(): Option {
    // ...
    if ($foundSomething) {
        return new Some($thing);
    } else {
        return new None;
    }
}

function findSomethingElse(): Result {
    // ...
    if ($foundSomething) {
        return new Some($thing);
    } else {
        return new None;
    }
}

// Fallback to value
$value = findSomething()->unwrapOr(null);

// Fallback to option and throw an exception if both fail
$value = findSomething()->or(findSomethingElse())->unwrap();

// Throw custom exception on missing thing (None)
$value = findSomething()->expect(new Exception("Oh noes!"));

License

MIT & Apache 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].