Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change OnceCell to OnceLock in TabExpandedString #694

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "indicatif"
version = "0.17.10"
version = "0.17.11"
edition = "2021"
rust-version = "1.70"
description = "A progress bar and cli reporting library for Rust"
Expand Down
18 changes: 18 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,21 @@ pub use crate::rayon::ParallelProgressIterator;
pub use crate::state::{ProgressFinish, ProgressState};
pub use crate::style::ProgressStyle;
pub use crate::term_like::TermLike;

#[cfg(test)]
mod tests {
use super::*;

#[allow(dead_code)]
trait MustBeThreadSafe: Send + Sync {}

// Ensure that the following types are `Send + Sync`
impl MustBeThreadSafe for MultiProgress {}
impl MustBeThreadSafe for MultiProgressAlignment {}
impl MustBeThreadSafe for ProgressBar {}
impl MustBeThreadSafe for ProgressBarIter<()> {}
impl MustBeThreadSafe for ProgressFinish {}
impl MustBeThreadSafe for ProgressState {}
impl MustBeThreadSafe for ProgressStyle {}
impl MustBeThreadSafe for WeakProgressBar {}
}
7 changes: 3 additions & 4 deletions src/state.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::borrow::Cow;
use std::cell::OnceCell;
use std::io;
use std::sync::Arc;
use std::sync::{Arc, OnceLock};
use std::time::Duration;
#[cfg(not(target_arch = "wasm32"))]
use std::time::Instant;
Expand Down Expand Up @@ -355,7 +354,7 @@ pub(crate) enum TabExpandedString {
NoTabs(Cow<'static, str>),
WithTabs {
original: Cow<'static, str>,
expanded: OnceCell<String>,
expanded: OnceLock<String>,
tab_width: usize,
},
}
Expand All @@ -368,7 +367,7 @@ impl TabExpandedString {
Self::WithTabs {
original: s,
tab_width,
expanded: OnceCell::new(),
expanded: OnceLock::new(),
}
}
}
Expand Down
Loading