Skip to content

Commit

Permalink
Docs updated
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorlott committed Jan 16, 2023
1 parent 38da8df commit 37a2ae2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "typer"
name = "typed"
version = "0.1.0"
edition = "2021"
description = "Get the types of a struct"
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,34 @@ trait Trait: Container::protocol {
fn extend(&mut self, val: Container::protocol::another);
}
```
### More
````rust
#[type_it]
struct Container<C: Clone, T = i64> {
a: i32,
b: Vec<i32>,
c: Vec<T>,
d: C,
e: T
}

#[type_it]
struct Tuple(i32, i32);

#[type_it]
struct Tuple2<T>(i32, T);

fn main() {
let a: Container::fields::a = 10;
let b: Container::b = vec![a];
let c: Container::c<i64> = vec![10];
let c: <Container::core<i64> as Container::protocol>::c = c;
let d: <Container::core<i64> as Container::protocol>::d = 10;
let container: Container::core<i64> = Container::core { a, b, c, d, e: 10 };

assert!(container.a == a);
}
````

# Disassembler
```rust
Expand Down
7 changes: 4 additions & 3 deletions tests/typed-test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(unused_variables)]

extern crate typer;
use typer::type_it;
extern crate typed;
use typed::type_it;

#[type_it]
struct Container<C: Clone, T = i64> {
Expand All @@ -21,7 +21,8 @@ struct Tuple2<T>(i32, T);
fn main() {
let a: Container::fields::a = 10;
let b: Container::b = vec![a];
let c: <Container::core<i64> as Container::protocol>::c = vec![10];
let c: Container::c<i64> = vec![10];
let c: <Container::core<i64> as Container::protocol>::c = c;
let d: <Container::core<i64> as Container::protocol>::d = 10;
let container: Container::core<i64> = Container::core { a, b, c, d, e: 10 };

Expand Down

0 comments on commit 37a2ae2

Please sign in to comment.