1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//! Knuth–Morris–Pratt pattern matching algorithm

// These are outright wrong and are forbidden to be allowed. This forces correct code.
// If there is indeed a false positive in one of these, they can still be moved to the deny section.
#![forbid(
    const_err,
    exceeding_bitshifts,
    future_incompatible,
    irrefutable_let_patterns,
    macro_use_extern_crate,
    mutable_transmutes,
    no_mangle_const_items,
    nonstandard_style,
    rust_2018_compatibility,
    rust_2018_idioms,
    trivial_casts,
    trivial_numeric_casts,
    unknown_crate_types,
    unreachable_pub,
    unsafe_code,
    unused,
    unused_import_braces,
    unused_lifetimes,
    unused_results,
    deprecated,
    illegal_floating_point_literal_pattern,
    improper_ctypes,
    intra_doc_link_resolution_failure,
    irrefutable_let_patterns,
    late_bound_lifetime_arguments,
    non_camel_case_types,
    non_shorthand_field_patterns,
    non_snake_case,
    non_upper_case_globals,
    no_mangle_generic_items,
    overflowing_literals,
    path_statements,
    patterns_in_fns_without_body,
    plugin_as_library,
    private_in_public,
    proc_macro_derive_resolution_fallback,
    renamed_and_removed_lints,
    safe_packed_borrows,
    stable_features,
    trivial_bounds,
    type_alias_bounds,
    tyvar_behind_raw_pointer,
    unconditional_recursion,
    unions_with_drop_fields,
    unknown_lints,
    unnameable_test_items,
    unreachable_patterns,
    unstable_name_collisions,
    where_clauses_object_safety,
    while_true,
    clippy::complexity,
    clippy::correctness,
    clippy::perf,
    clippy::style
)]
// These are denied so one is forced to annotate expected behaviour by allowing it.
#![deny(
    dead_code,
    missing_copy_implementations,
    unconditional_recursion,
    unreachable_code,
    unused_qualifications,
    variant_size_differences,
    clippy::cast_possible_truncation,
    clippy::cast_possible_wrap,
    clippy::cast_precision_loss,
    clippy::cast_sign_loss,
    clippy::decimal_literal_representation,
    clippy::empty_line_after_outer_attr,
    clippy::eval_order_dependence,
    clippy::indexing_slicing,
    clippy::mutex_integer,
    clippy::needless_pass_by_value,
    clippy::non_ascii_literal,
    clippy::nursery,
    clippy::option_unwrap_used,
    clippy::pedantic,
    clippy::restriction,
    clippy::result_unwrap_used
)]
// These can either not be #[allow()]'d, have false-positives or are development-tools
// of which we only care about in the CI.
#![warn(
    missing_docs,
    missing_doc_code_examples,
    single_use_lifetimes,
    clippy::missing_docs_in_private_items,
    clippy::float_arithmetic,
    clippy::inline_always,
    clippy::integer_arithmetic,
    clippy::missing_inline_in_public_items,
    clippy::multiple_crate_versions,
    clippy::shadow_reuse,
    clippy::shadow_same,
    clippy::unimplemented,
    clippy::use_self
)]
#![allow(
    box_pointers,
    missing_debug_implementations,
    clippy::cargo,
    clippy::implicit_return,
    clippy::missing_inline_in_public_items
)]
// allow unwraps and unused results in tests
#![cfg_attr(test, allow(clippy::option_unwrap_used, clippy::result_unwrap_used))]
#![cfg_attr(test, allow(unused_results))]
// allow this for now, until 1.0
#![allow(clippy::module_name_repetitions)]
#![no_std]
extern crate alloc;

pub use find::{kmp_find, kmp_find_with_lsp_table};
pub use r#match::{kmp_match, kmp_match_with_lsp_table};
pub use table::kmp_table;

/// Module for a basic search returning the first found position.
mod find;
/// Module for finding multiple locations.
mod r#match;
/// Module for everything related to generating a `longest suffix-prefix` table.
mod table;