Debian Codegraph @

debian/missing-sources/string_cache/src/static_sets.rs

raw symbols SCIP
1 // Copyright 2014 The Servo Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10 /// A static `PhfStrSet`
11 ///
12 /// This trait is implemented by static sets of interned strings generated using
13 /// `string_cache_codegen`, and `EmptyStaticAtomSet` for when strings will be added dynamically.
14 ///
15 /// It is used by the methods of [`Atom`] to check if a string is present in the static set.
16 ///
17 /// [`Atom`]: struct.Atom.html
18 pub trait StaticAtomSetrust-analyzer cargo string_cache 0.9.0 static_sets/StaticAtomSet#: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# {
19 /// Get the location of the static string set in the binary.
20 fn getrust-analyzer cargo string_cache 0.9.0 static_sets/StaticAtomSet#get().() -> &'static PhfStrSetrust-analyzer cargo string_cache 0.9.0 static_sets/PhfStrSet#;
21 /// Get the index of the empty string, which is in every set and is used for `Atom::default`.
22 fn empty_string_indexrust-analyzer cargo string_cache 0.9.0 static_sets/StaticAtomSet#empty_string_index().() -> u32;
23 }
24
25 /// A string set created using a [perfect hash function], specifically
26 /// [Hash, Displace and Compress].
27 ///
28 /// See the CHD document for the meaning of the struct fields.
29 ///
30 /// [perfect hash function]: https://en.wikipedia.org/wiki/Perfect_hash_function
31 /// [Hash, Displace and Compress]: http://cmph.sourceforge.net/papers/esa09.pdf
32 pub struct PhfStrSetrust-analyzer cargo string_cache 0.9.0 static_sets/PhfStrSet# {
33 #[doc(hidden)]
34 pub keyrust-analyzer cargo string_cache 0.9.0 static_sets/PhfStrSet#key.: u64,
35 #[doc(hidden)]
36 pub dispsrust-analyzer cargo string_cache 0.9.0 static_sets/PhfStrSet#disps.: &'static [(u32, u32)],
37 #[doc(hidden)]
38 pub atomsrust-analyzer cargo string_cache 0.9.0 static_sets/PhfStrSet#atoms.: &'static [&'static str],
39 #[doc(hidden)]
40 pub hashesrust-analyzer cargo string_cache 0.9.0 static_sets/PhfStrSet#hashes.: &'static [u32],
41 }
42
43 /// An empty static atom set for when only dynamic strings will be added
44 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:)]
45 pub struct EmptyStaticAtomSetrust-analyzer cargo string_cache 0.9.0 static_sets/EmptyStaticAtomSet#;
46
47 impl StaticAtomSetrust-analyzer cargo string_cache 0.9.0 static_sets/StaticAtomSet# for EmptyStaticAtomSetrust-analyzer cargo string_cache 0.9.0 static_sets/EmptyStaticAtomSet# {
48 fn getrust-analyzer cargo string_cache 0.9.0 static_sets/impl#[EmptyStaticAtomSet][StaticAtomSet]get().() -> &'static PhfStrSetrust-analyzer cargo string_cache 0.9.0 static_sets/PhfStrSet# {
49 // The name is a lie: this set is not empty (it contains the empty string)
50 // but that’s only to avoid divisions by zero in rust-phf.
51 static SETrust-analyzer cargo string_cache 0.9.0 static_sets/SET.: PhfStrSetrust-analyzer cargo string_cache 0.9.0 static_sets/PhfStrSet# = PhfStrSetrust-analyzer cargo string_cache 0.9.0 static_sets/PhfStrSet# {
52 keyrust-analyzer cargo string_cache 0.9.0 static_sets/PhfStrSet#key.: 0,
53 dispsrust-analyzer cargo string_cache 0.9.0 static_sets/PhfStrSet#disps.: &[(0, 0)],
54 atomsrust-analyzer cargo string_cache 0.9.0 static_sets/PhfStrSet#atoms.: &[""],
55 // "" SipHash'd, and xored with u64_hash_to_u32.
56 hashesrust-analyzer cargo string_cache 0.9.0 static_sets/PhfStrSet#hashes.: &[0x3ddddef3],
57 };
58 &SETrust-analyzer cargo string_cache 0.9.0 static_sets/SET.
59 }
60
61 fn empty_string_indexrust-analyzer cargo string_cache 0.9.0 static_sets/impl#[EmptyStaticAtomSet][StaticAtomSet]empty_string_index().() -> u32 {
62 0
63 }
64 }