tupleops_generator/lib.rs
1// Copyright (c) 2021 René Kijewski <rene.[SURNAME]@fu-berlin.de>
2// All rights reserved.
3//
4// This software and the accompanying materials are made available under
5// the terms of the ISC License which is available in the project root as LICENSE-ISC, AND/OR
6// the terms of the MIT License which is available at in the project root as LICENSE-MIT, AND/OR
7// the terms of the Apache License, Version 2.0 which is available in the project root as LICENSE-APACHE.
8//
9// You have to accept AT LEAST one of the aforementioned licenses to use, copy, modify, and/or distribute this software.
10// At your will you may redistribute the software under the terms of only one, two, or all three of the aforementioned licenses.
11
12#![forbid(unsafe_code)]
13
14//! Functions to generate the code of [tupleop](https://crates.io/crates/tupleops) trait implementations.
15
16mod common;
17mod one_arg;
18
19use std::fmt::Error;
20
21use common::gen_range;
22
23macro_rules! implement {
24 () => {};
25
26 ( $name:ident ) => {
27 pub fn $name(dest: &mut String, from: usize, to: usize) -> Result<(), Error> {
28 gen_range(dest, from, to, one_arg::$name)
29 }
30 };
31
32 ( $name:ident $($names:ident)+ ) => {
33 implement! { $name }
34 implement! { $($names)+ }
35 };
36}
37
38implement! {
39 tuple_all_ok
40 tuple_all_some
41 tuple_append
42 tuple_apply
43 tuple_concat_many
44 tuple_concat
45 tuple_length
46 tuple_map
47 tuple_option
48 tuple_prepend
49 tuple_ref_mut
50 tuple_ref
51 tuple_tuple
52 tuple_unappend
53 tuple_unprepend
54}