MCPcopy Create free account
hub / github.com/QMHTMY/RustBook / main

Function main

publication/code/chapter10/conshash.rs:98–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

96}
97
98fn main() {
99 let replica = 3;
100 let mut ring = Ring::with_capacity(replica);
101
102 let node = Node{
103 host: "localhost",
104 ip: "127.0.0.1",
105 port: 23,
106 };
107 ring.add(&node);
108
109 for i in 0..replica {
110 let key = hash(&(node.to_string() + &i.to_string()));
111 let res = ring.get(key);
112 assert_eq!(node.host, res.unwrap().host);
113 }
114
115 println!("{:?}", &node);
116 ring.remove(&node);
117}

Callers

nothing calls this directly

Calls 5

hashFunction · 0.70
addMethod · 0.45
to_stringMethod · 0.45
getMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected