clingo-derive

Crates.ioclingo-derive
lib.rsclingo-derive
version0.2.0
created_at2019-06-28 14:28:28.21342+00
updated_at2019-11-07 10:40:28.609297+00
descriptionDerive macro for the clingo crate
homepage
repositoryhttps://github.com/potassco/clingo_derive
max_upload_size
id144319
size13,193
Sven Thiele (sthiele)

documentation

https://docs.rs/clingo_derive

README

Build Status

clingo_derive

This crate provides the derive macro for the clingo::ToSymbol trait. Datatypes that implement this trait can be added to a clingo::FactBase

In your Cargo.toml add:

[dependencies]
clingo = { version = "0.6", features = ["derive"] }

In your source write:

use clingo::ToSymbol;
use clingo::ClingoError;
use clingo::FactBase;

#[derive(ToSymbol)]
struct Point {
    x: i32,
    y: i32,
}

let p = Point{ x:4, y:2 };
let fb = FactBase::new();
fb.insert(p);

The macro performs a conversion to snake case. This means the corresponing fact for MyPoint{x:3,y:2} is my_point(3,2).

Commit count: 0

cargo fmt