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

Function main

code/chapter09/conshash.rs:95–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected