Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jan 12, 2023
1 parent 9413652 commit fdf7dcb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ let id = g.kid(0, "foo")?; // returns 1
You can find all kids of a vertex:

```rust
let kids: Vec<(String, u32)> = g.kids(0);
let kids: Vec<(String, String, u32)> = g.kids(0);
```

You can read the data of a vertex:

```rust
let bytes: Hex = g.data(1)?.to_i64()?;
let hex: Hex = g.data(1)?;
let num: i64 = hex.to_i64()?;
```

Then, you can print the graph:
Expand Down
13 changes: 6 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ pub(crate) use crate::vertex::Vertex;

/// This struct represents a Surging Object DiGraph (SODG).
///
/// You add vertices
/// to it, bind them one to one with edges, put data into some of them,
/// and read data back:
/// You add vertices to it, bind them one to one with edges,
/// put data into some of them, and read data back:
///
/// ```
/// use sodg::Sodg;
Expand Down Expand Up @@ -111,14 +110,14 @@ pub trait Relay {
fn re(&self, v: u32, a: &str, b: &str) -> Result<String>;
}

/// This `Relay` doesn't even try to find anything, but returns
/// an error.
/// This `Relay` doesn't even try to find anything, but returns an error.
///
/// If you don't know what relay to use, use [`DeadRelay::new()`].
pub struct DeadRelay {}

/// This `Relay` can be made of a lambda function. The function must
/// accept three arguments: `v` is the ID of the vertex where an attribute
/// This `Relay` can be made of a lambda function.
///
/// The function must accept three arguments: `v` is the ID of the vertex where an attribute
/// is not found, `a` is the name of the attribute, `b` is the optional locator
/// of the attribute. The function must return a new locator where the
/// search algorithm must continue. It can be just a name of a new attribute,
Expand Down
2 changes: 2 additions & 0 deletions src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use crate::Sodg;
impl Sodg {
/// Is it empty?
///
/// Emptiness means that not a single vertex is there.
///
/// ```
/// use sodg::Sodg;
/// let mut sodg = Sodg::empty();
Expand Down
3 changes: 1 addition & 2 deletions src/next.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ use crate::Sodg;
impl Sodg {
/// Get next unique ID of a vertex.
///
/// This ID will never be
/// returned by `next()` again. Also, this ID will not
/// This ID will never be returned by `next()` again. Also, this ID will not
/// be equal to any of the existing IDs of vertices.
pub fn next_id(&mut self) -> u32 {
let mut id = self.next_v;
Expand Down

0 comments on commit fdf7dcb

Please sign in to comment.