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

Function try_insert

publication/code/chapter10/cuckoofilter/src/lib.rs:76–82  ·  view source on GitHub ↗

尝试插入

(&mut self, elem: &T)

Source from the content-addressed store, hash-verified

74
75 // 尝试插入
76 fn try_insert<T: ?Sized + Hash>(&mut self, elem: &T) -> Result<bool, CuckooError> {
77 if self.contains(elem) {
78 Ok(false)
79 } else {
80 self.insert(elem).map(|_| true)
81 }
82 }
83
84 fn insert<T: ?Sized + Hash>(&mut self, elem: &T) -> Result<(), CuckooError> {
85 let fai = FaI::from_data::<_, H>(elem)

Callers

nothing calls this directly

Calls 2

containsMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected