fieldenum


Namefieldenum JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryRust-like fielded Enums in Python
upload_time2024-09-05 08:28:41
maintainerNone
docs_urlNone
authorilotoki0804
requires_python<4.0,>=3.10
licenseMIT
keywords enum dataclass rust functional
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # fieldenum

[![PyPI - Downloads](https://img.shields.io/pypi/dm/fieldenum)](https://pypi.org/project/fieldenum/)
[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Filotoki0804%2Ffieldenum&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://github.com/ilotoki0804/fieldenum)
[![Coverage Status](https://coveralls.io/repos/github/ilotoki0804/fieldenum/badge.svg?branch=master)](https://coveralls.io/github/ilotoki0804/fieldenum?branch=master)
[![Sponsoring](https://img.shields.io/badge/Sponsoring-Toss-blue?logo=GitHub%20Sponsors&logoColor=white)](https://toss.me/ilotoki)

Rust-like fielded Enums in Python

**[한국어로 보기](docs/README-ko.md)**

## Examples

```python
from fieldenum import fieldenum, Unit, Variant

@fieldenum
class Message:
    Quit = Unit
    Move = Variant(x=int, y=int)
    Write = Variant(str)
    ChangeColor = Variant(int, int, int)

# Corresponding code in Rust:
# enum Message {
#     Quit,
#     Move { x: i32, y: i32 },
#     Write(String),
#     ChangeColor(i32, i32, i32),
# }


# usage
message = Message.Quit
message = Message.Move(x=1, y=2)
message = Message.Write("hello, world!")
message = Message.ChangeColor(256, 256, 0)
```

## Credits

This project is heavily influenced by [Rust's `Enum`](https://doc.rust-lang.org/reference/items/enumerations.html), and also borrows some of its design from [rust_enum](https://github.com/girvel/rust_enum).

## Releases

* 0.1.0: initial release

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "fieldenum",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "enum, dataclass, rust, functional",
    "author": "ilotoki0804",
    "author_email": "ilotoki0804@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0a/8e/546e898513bda0b3f7b6e90288e0e0e4c0f067ca5e1dd77319c047598b84/fieldenum-0.2.0.tar.gz",
    "platform": null,
    "description": "# fieldenum\n\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/fieldenum)](https://pypi.org/project/fieldenum/)\n[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Filotoki0804%2Ffieldenum&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://github.com/ilotoki0804/fieldenum)\n[![Coverage Status](https://coveralls.io/repos/github/ilotoki0804/fieldenum/badge.svg?branch=master)](https://coveralls.io/github/ilotoki0804/fieldenum?branch=master)\n[![Sponsoring](https://img.shields.io/badge/Sponsoring-Toss-blue?logo=GitHub%20Sponsors&logoColor=white)](https://toss.me/ilotoki)\n\nRust-like fielded Enums in Python\n\n**[\ud55c\uad6d\uc5b4\ub85c \ubcf4\uae30](docs/README-ko.md)**\n\n## Examples\n\n```python\nfrom fieldenum import fieldenum, Unit, Variant\n\n@fieldenum\nclass Message:\n    Quit = Unit\n    Move = Variant(x=int, y=int)\n    Write = Variant(str)\n    ChangeColor = Variant(int, int, int)\n\n# Corresponding code in Rust:\n# enum Message {\n#     Quit,\n#     Move { x: i32, y: i32 },\n#     Write(String),\n#     ChangeColor(i32, i32, i32),\n# }\n\n\n# usage\nmessage = Message.Quit\nmessage = Message.Move(x=1, y=2)\nmessage = Message.Write(\"hello, world!\")\nmessage = Message.ChangeColor(256, 256, 0)\n```\n\n## Credits\n\nThis project is heavily influenced by [Rust's `Enum`](https://doc.rust-lang.org/reference/items/enumerations.html), and also borrows some of its design from [rust_enum](https://github.com/girvel/rust_enum).\n\n## Releases\n\n* 0.1.0: initial release\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Rust-like fielded Enums in Python",
    "version": "0.2.0",
    "project_urls": {
        "Repository": "https://github.com/ilotoki0804/fieldenum"
    },
    "split_keywords": [
        "enum",
        " dataclass",
        " rust",
        " functional"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "71b6008ce14dd5429a1133ac253ce1de7aabdc6f4fcfab4e589802c45a66bb86",
                "md5": "0f8474299a37b20561a07a6df544480f",
                "sha256": "ec5a6b12f463fb8769530794016054b9b7990206f9e2ecec1c6e11ab94353a8b"
            },
            "downloads": -1,
            "filename": "fieldenum-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0f8474299a37b20561a07a6df544480f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 9767,
            "upload_time": "2024-09-05T08:28:40",
            "upload_time_iso_8601": "2024-09-05T08:28:40.490400Z",
            "url": "https://files.pythonhosted.org/packages/71/b6/008ce14dd5429a1133ac253ce1de7aabdc6f4fcfab4e589802c45a66bb86/fieldenum-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0a8e546e898513bda0b3f7b6e90288e0e0e4c0f067ca5e1dd77319c047598b84",
                "md5": "ef05aa0bebb1e582fa5d39e5c96f6b0b",
                "sha256": "7997d97154b86fd2fed3df9951539cb2b9ae4b26f38f71185fdea98423a3ada2"
            },
            "downloads": -1,
            "filename": "fieldenum-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ef05aa0bebb1e582fa5d39e5c96f6b0b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 9208,
            "upload_time": "2024-09-05T08:28:41",
            "upload_time_iso_8601": "2024-09-05T08:28:41.888324Z",
            "url": "https://files.pythonhosted.org/packages/0a/8e/546e898513bda0b3f7b6e90288e0e0e4c0f067ca5e1dd77319c047598b84/fieldenum-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-05 08:28:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ilotoki0804",
    "github_project": "fieldenum",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fieldenum"
}
        
Elapsed time: 0.87459s