From bf4db99465d021d1761b8014af1ec28d51b4b7e2 Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 21 Jan 2024 22:30:25 -0600 Subject: [PATCH] remove dependency on nightly --- Cargo.lock | 1 + Cargo.toml | 1 + src/engines/answer/calc.rs | 5 +++-- src/engines/mod.rs | 4 ++-- src/engines/postsearch/github.rs | 2 +- src/engines/search/marginalia.rs | 2 +- src/main.rs | 2 -- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c085a6c..321c02c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -937,6 +937,7 @@ dependencies = [ "fend-core", "futures", "html-escape", + "once_cell", "rand", "regex", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index 2479600..92aa10f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ eyre = "0.6.11" fend-core = "1.3.3" futures = "0.3.29" html-escape = "0.2.13" +once_cell = "1.19.0" rand = "0.8.5" regex = "1.10.2" reqwest = { version = "0.11.23", default-features = false, features = [ diff --git a/src/engines/answer/calc.rs b/src/engines/answer/calc.rs index 06dee4a..61b435b 100644 --- a/src/engines/answer/calc.rs +++ b/src/engines/answer/calc.rs @@ -1,6 +1,7 @@ -use std::{cell::Cell, sync::LazyLock}; +use std::cell::Cell; use fend_core::SpanKind; +use once_cell::sync::Lazy; use crate::engines::EngineResponse; @@ -96,7 +97,7 @@ fn evaluate(query: &str, html: bool) -> Option { Some(result_html) } -pub static FEND_CONTEXT: LazyLock = LazyLock::new(|| { +pub static FEND_CONTEXT: Lazy = Lazy::new(|| { let mut context = fend_core::Context::new(); // make lowercase f and c work diff --git a/src/engines/mod.rs b/src/engines/mod.rs index 6487b7b..401fade 100644 --- a/src/engines/mod.rs +++ b/src/engines/mod.rs @@ -4,11 +4,11 @@ use std::{ net::IpAddr, ops::Deref, str::FromStr, - sync::LazyLock, time::Instant, }; use futures::future::join_all; +use once_cell::sync::Lazy; use reqwest::header::HeaderMap; use tokio::sync::mpsc; @@ -400,7 +400,7 @@ pub async fn autocomplete_with_engines( Ok(merge_autocomplete_responses(autocomplete_results)) } -pub static CLIENT: LazyLock = LazyLock::new(|| { +pub static CLIENT: Lazy = Lazy::new(|| { reqwest::ClientBuilder::new() .local_address(IpAddr::from_str("0.0.0.0").unwrap()) // we pretend to be a normal browser so websites don't block us diff --git a/src/engines/postsearch/github.rs b/src/engines/postsearch/github.rs index 42b8de9..8f1e9c7 100644 --- a/src/engines/postsearch/github.rs +++ b/src/engines/postsearch/github.rs @@ -48,7 +48,7 @@ pub fn parse_response(body: &str) -> Option { .url_relative(ammonia::UrlRelative::RewriteWithBase( Url::parse("https://github.com").unwrap(), )) - .clean(&readme_html) + .clean(readme_html) .to_string(); let readme_dom = Html::parse_fragment(&readme_html); diff --git a/src/engines/search/marginalia.rs b/src/engines/search/marginalia.rs index fdbc421..7a9eeb8 100644 --- a/src/engines/search/marginalia.rs +++ b/src/engines/search/marginalia.rs @@ -19,7 +19,7 @@ pub fn request(query: &str) -> RequestResponse { "https://search.marginalia.nu/search", &[ ("query", query), - ("profile", "default"), + ("profile", "corpo"), ("js", "default"), ("adtech", "default"), ], diff --git a/src/main.rs b/src/main.rs index 01fc6c4..d8bad37 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,3 @@ -#![feature(lazy_cell)] - pub mod engines; pub mod normalize; pub mod parse;