Skip to content

Commit

Permalink
use OnceLock from std instead of the once_cell crate (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayrat555 authored Sep 8, 2023
1 parent 9084ee8 commit acca60d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 62 deletions.
91 changes: 36 additions & 55 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ rust-version = "1.62"

[dependencies]
thiserror = "1.0"
once_cell = "1.16"
aho-corasick = "1.0"
atom_syndication = "0.12"
chrono = "0.4"
Expand Down
4 changes: 2 additions & 2 deletions src/bot/telegram_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ use frankenstein::Update;
use isahc::prelude::*;
use isahc::HttpClient;
use isahc::Request;
use once_cell::sync::OnceCell;
use std::collections::VecDeque;
use std::path::PathBuf;
use std::sync::OnceLock;
use typed_builder::TypedBuilder;

static API: OnceCell<Api> = OnceCell::new();
static API: OnceLock<Api> = OnceLock::new();

#[derive(Clone, Debug)]
pub struct Api {
Expand Down
4 changes: 2 additions & 2 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use chrono::prelude::*;
use chrono::{DateTime, Utc};
use diesel::pg::PgConnection;
use diesel::r2d2;
use once_cell::sync::OnceCell;
use std::sync::OnceLock;

#[cfg(test)]
use diesel::connection::Connection;
Expand All @@ -15,7 +15,7 @@ pub mod feed_items;
pub mod feeds;
pub mod telegram;

static POOL: OnceCell<r2d2::Pool<r2d2::ConnectionManager<PgConnection>>> = OnceCell::new();
static POOL: OnceLock<r2d2::Pool<r2d2::ConnectionManager<PgConnection>>> = OnceLock::new();

#[cfg(test)]
pub fn establish_test_connection() -> PgConnection {
Expand Down
4 changes: 2 additions & 2 deletions src/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use crate::config::Config;
use isahc::config::RedirectPolicy;
use isahc::prelude::*;
use isahc::HttpClient;
use once_cell::sync::OnceCell;
use std::sync::OnceLock;
use std::time::Duration;

static CLIENT: OnceCell<HttpClient> = OnceCell::new();
static CLIENT: OnceLock<HttpClient> = OnceLock::new();

pub fn client() -> &'static HttpClient {
CLIENT.get_or_init(init_client)
Expand Down

0 comments on commit acca60d

Please sign in to comment.