memacc 0.1.11

Memory access functions.
Documentation
from datetime import datetime
from pathlib import Path
from string import Template

template_str = """\
impl IndexRangeU$width for IR<$start, $end> {
    #[inline]
    #[must_use]
    fn start(self) -> u$width {
        $start
    }
    #[inline]
    #[must_use]
    fn end(self) -> u$width {
        $end
    }
}"""
template = Template(template_str)

if __name__ == "__main__":
    path_output = Path(__file__).parent.parent / Path(
        "src/bitman/checked/indices/generated.rs"
    )
    path_output = path_output.resolve()
    output = list()
    output.append(f"//! This file is automatically generated.")
    output.append(f"//!")
    output.append(f"""//! Date: {datetime.now().isoformat(timespec="seconds")}""")
    output.append(f"use crate::bitman::checked::indices::IndexRangeU8;")
    output.append(f"use crate::bitman::checked::indices::IndexRangeU32;")
    output.append(f"use crate::bitman::checked::indices::IR;")
    for start in range(8):
        for end in range(8):
            if start <= end:
                output.append(
                    template.substitute({"width": 8, "start": start, "end": end})
                )
    for start in range(32):
        for end in range(32):
            if start <= end:
                output.append(
                    template.substitute({"width": 32, "start": start, "end": end})
                )
    output_str = "\n".join(output)
    with path_output.open("w") as stream:
        stream.write(output_str)