datrs / hypercore

Secure, distributed, append-only log
https://docs.rs/hypercore
Apache License 2.0
332 stars 37 forks source link

README is incorrect about what the sample code prints #74

Open tekknolagi opened 5 years ago

tekknolagi commented 5 years ago

Bug Report

Your Environment

Software Version(s)
hypercore 0.9.0
Rustc rustc 1.35.0-nightly (237bf3244 2019-03-28)
Operating System Ubuntu 18.04

Expected Behavior

Program prints

hello
world

Current Behavior

Program prints

Ok(Some([104, 101, 108, 108, 111]))
Ok(Some([119, 111, 114, 108, 100]))

Code Sample

extern crate hypercore;

use hypercore::Feed;
use std::path::PathBuf;

let path = PathBuf::from("./my-first-dataset");
let mut feed = Feed::new(&path).unwrap();

feed.append(b"hello").unwrap();
feed.append(b"world").unwrap();

println!("{:?}", feed.get(0)); // prints "hello"
println!("{:?}", feed.get(1)); // prints "world"
yoshuawuyts commented 5 years ago

Oh yeah, it should be an assertion instead:

assert_eq!(feed.get(0)?, Some(b"hello"));
assert_eq!(feed.get(1)?, Some(b"world"));