https://github.com/philippmdoerner/mapster
A simple way to generate mapping functions at compile-time without having to write them yourself.
https://github.com/philippmdoerner/mapster
map mapping nim nim-lang nim-language pragma
Last synced: 20 days ago
JSON representation
A simple way to generate mapping functions at compile-time without having to write them yourself.
- Host: GitHub
- URL: https://github.com/philippmdoerner/mapster
- Owner: PhilippMDoerner
- Created: 2023-07-28T15:24:19.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-08T03:37:45.000Z (10 months ago)
- Last Synced: 2025-03-23T18:48:08.766Z (about 1 month ago)
- Topics: map, mapping, nim, nim-lang, nim-language, pragma
- Language: Nim
- Homepage:
- Size: 109 KB
- Stars: 16
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
Awesome Lists containing this project
README
# Mapster
[](https://github.com/PhilippMDoerner/mapster/actions/workflows/tests.yml)
#### _Because life's too short to map A to B_
**Mapster** is a simple package to help generate procedures/functions for you to map an instance of type A to type B.Very often A and B share a lot of fields and there is only a small set of exceptions where actual logic is required.
Mapster helps by adding all assignments from instance A to B to the proc for you where the field names and types are identical, allowing you to focus on the few fields that require logic.
- [Documentation](https://philippmdoerner.github.io/mapster/index.html) (built with [nimibook](https://github.com/pietroppeter/nimibook))
## Installation
Install Mapster with Nimble:
$ nimble install -y mapster
Add Mapster to your .nimble file:
requires "mapster"
## Supports
### Operations
- Single Parameter mapping procs(A --> B)
- Multi Parameter mapping procs ((A1, A2, ...) --> B)
- In-place mapping procs (var A, B)
- Multi Parameter in-place mapping procs (var A, B1, B2, ...)
- Any amount of custom assignments or logic within the (in-place) mapping procs
- Optional: Compile-time validation for your (in-place) mapping procs!### Types
- Object types
- Object Variant Types (only with `mapVariant`)
- Ref Object Types
- Ref Object Variant Types (only with `mapVariant`)
- Named Tuple Types## Getting Started
Take a look at the [nimibook docs](https://philippmdoerner.github.io/mapster/basicUsage.html)!