Skip to content

Commit d55e517

Browse files
committed
Merge branch 'release/0.7.6'
2 parents a63e561 + 6444735 commit d55e517

File tree

6 files changed

+95
-113
lines changed

6 files changed

+95
-113
lines changed

Cargo.lock

Lines changed: 23 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
authors = ["Jorge D. Ortiz-Fuentes <jdortiz@gmail.com>"]
33
name = "lazycoder"
44
description = "Simple snippet provider for espanso."
5-
version = "0.7.5"
5+
version = "0.7.6"
66
edition = "2021"
77

88
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -11,12 +11,12 @@ edition = "2021"
1111
clap = { version = "~4.5", features = ["derive"] }
1212
directories = "~6.0"
1313
env_logger = "~0.11"
14-
eyre = "0.6.12"
14+
eyre = "~0.6"
1515
log = "~0.4"
1616
mockall_double = "~0.3"
1717
serde = "^1.0"
1818
serde_derive = "^1.0"
19-
toml = "~0.8"
19+
toml = "~0.9"
2020

2121
[dev-dependencies]
2222
mockall = "~0.13"

src/config.rs

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl Config {
3434
/// * `path` - path to the file with the snippets that will be stored in the configuration.
3535
pub fn new(path: &Path) -> Result<Self, LazyCoderError> {
3636
if let Ok(absolute_path) = canonicalize(path) {
37-
debug!("{:?} does exist", absolute_path);
37+
debug!("{absolute_path:?} does exist");
3838
let new_config = Config {
3939
file_path: absolute_path.to_str().unwrap().to_string(),
4040
position: 0,
@@ -163,21 +163,21 @@ mod tests {
163163
use super::*;
164164

165165
thread_local! {
166-
static CANONIZALIZE_ANSWER: Cell<Option<PathBuf>> = Cell::new(None);
167-
static CONFIG_DIR_ANSWER: Cell<Option<PathBuf>> = Cell::new(None);
168-
static CREATE_DIR_OK_ANSWER: Cell<bool> = Cell::new(true);
169-
static CREATE_DIR_ALL_ARG: Cell<Option<PathBuf>> = Cell::new(None);
170-
static PATH_EXISTS_ANSWER: Cell<bool> = Cell::new(true);
171-
static READ_TO_STRING_ANSWER: Cell<Option<String>> = Cell::new(None);
172-
static SNIPPET_PROVIDER_ANSWER: Cell<Option<Box<dyn SnippetProvider>>> = Cell::new(None);
173-
static WRITE_OK_ANSWER: Cell<bool> = Cell::new(true);
174-
static WRITE_ARG_PATH: Cell<Option<PathBuf>> = Cell::new(None);
175-
static WRITE_ARG_CONTENTS: Cell<Option<String>> = Cell::new(None);
166+
static CANONICALIZE_ANSWER: Cell<Option<PathBuf>> = const { Cell::new(None) };
167+
static CONFIG_DIR_ANSWER: Cell<Option<PathBuf>> = const { Cell::new(None) };
168+
static CREATE_DIR_OK_ANSWER: Cell<bool> = const { Cell::new(true) };
169+
static CREATE_DIR_ALL_ARG: Cell<Option<PathBuf>> = const { Cell::new(None) };
170+
static PATH_EXISTS_ANSWER: Cell<bool> = const { Cell::new(true) };
171+
static READ_TO_STRING_ANSWER: Cell<Option<String>> = const { Cell::new(None) };
172+
static SNIPPET_PROVIDER_ANSWER: Cell<Option<Box<dyn SnippetProvider>>> = const { Cell::new(None) };
173+
static WRITE_OK_ANSWER: Cell<bool> = const { Cell::new(true) };
174+
static WRITE_ARG_PATH: Cell<Option<PathBuf>> = const { Cell::new(None) };
175+
static WRITE_ARG_CONTENTS: Cell<Option<String>> = const { Cell::new(None) };
176176
}
177177

178178
#[test]
179179
fn config_new_from_non_existing_path_fails() {
180-
CANONIZALIZE_ANSWER.set(None);
180+
CANONICALIZE_ANSWER.set(None);
181181

182182
let sut = Config::new(Path::new(""));
183183

@@ -188,7 +188,7 @@ mod tests {
188188
fn config_new_from_existing_path_is_created() {
189189
let mut path = PathBuf::new();
190190
path.push("/tmp");
191-
CANONIZALIZE_ANSWER.set(Some(path));
191+
CANONICALIZE_ANSWER.set(Some(path));
192192
CONFIG_DIR_ANSWER.set(Some(PathBuf::from_str("Some path").unwrap()));
193193

194194
let sut = Config::new(Path::new("/tmp"));
@@ -323,8 +323,7 @@ mod tests {
323323

324324
assert!(
325325
matches!(snippet, Ok(ref text) if text == "Some snippet"),
326-
"Snippet: {:?}",
327-
snippet
326+
"Snippet: {snippet:?}"
328327
);
329328
path_buf.push(FILE_NAME);
330329
assert_eq!(WRITE_ARG_PATH.take(), Some(path_buf));
@@ -357,8 +356,7 @@ mod tests {
357356

358357
assert!(
359358
matches!(snippet, Err(LazyCoderError::RunOutOfSnippets)),
360-
"Snippet: {:?}",
361-
snippet
359+
"Snippet: {snippet:?}"
362360
);
363361
assert_eq!(WRITE_ARG_PATH.take(), None);
364362
assert_eq!(WRITE_ARG_CONTENTS.take(), None);
@@ -383,8 +381,7 @@ mod tests {
383381

384382
assert!(
385383
matches!(snippet, Err(LazyCoderError::ConfigDirError)),
386-
"Snippet: {:?}",
387-
snippet
384+
"Snippet: {snippet:?}"
388385
);
389386
assert_eq!(WRITE_ARG_PATH.take(), None);
390387
assert_eq!(WRITE_ARG_CONTENTS.take(), None);
@@ -411,8 +408,7 @@ mod tests {
411408

412409
assert!(
413410
matches!(snippet, Ok(ref text) if text == "Some snippet"),
414-
"Snippet: {:?}",
415-
snippet
411+
"Snippet: {snippet:?}"
416412
);
417413
}
418414

@@ -437,8 +433,7 @@ mod tests {
437433

438434
assert!(
439435
matches!(snippet, Err(LazyCoderError::RunOutOfSnippets)),
440-
"Snippet: {:?}",
441-
snippet
436+
"Snippet: {snippet:?}"
442437
);
443438
}
444439

@@ -515,13 +510,13 @@ mod tests {
515510
use crate::{lazy_coder_error::LazyCoderError, snippet_handler::SnippetProvider};
516511

517512
use super::{
518-
CANONIZALIZE_ANSWER, CONFIG_DIR_ANSWER, CREATE_DIR_ALL_ARG, CREATE_DIR_OK_ANSWER,
513+
CANONICALIZE_ANSWER, CONFIG_DIR_ANSWER, CREATE_DIR_ALL_ARG, CREATE_DIR_OK_ANSWER,
519514
PATH_EXISTS_ANSWER, READ_TO_STRING_ANSWER, SNIPPET_PROVIDER_ANSWER, WRITE_ARG_CONTENTS,
520515
WRITE_ARG_PATH, WRITE_OK_ANSWER,
521516
};
522517

523518
pub fn canonicalize<P: AsRef<Path>>(_path: P) -> io::Result<PathBuf> {
524-
match CANONIZALIZE_ANSWER.take() {
519+
match CANONICALIZE_ANSWER.take() {
525520
Some(path_buf) => Ok(path_buf),
526521
None => Err(io::Error::other("Some error")),
527522
}

src/lazy_coder_error.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,8 @@ mod tests {
7070
#[test]
7171
fn display_snippet_file_error() {
7272
assert_eq!(
73-
LazyCoderError::SnippetFileError(std::io::Error::new(
74-
std::io::ErrorKind::Other,
75-
"some file error"
76-
))
77-
.to_string(),
73+
LazyCoderError::SnippetFileError(std::io::Error::other("some file error".to_string()))
74+
.to_string(),
7875
"snippet file error: some file error"
7976
)
8077
}
@@ -98,11 +95,8 @@ mod tests {
9895
#[test]
9996
fn display_config_file_error() {
10097
assert_eq!(
101-
LazyCoderError::ConfigFileError(std::io::Error::new(
102-
std::io::ErrorKind::Other,
103-
"some file error"
104-
))
105-
.to_string(),
98+
LazyCoderError::ConfigFileError(std::io::Error::other("some file error".to_string()))
99+
.to_string(),
106100
"configuration file error: some file error"
107101
)
108102
}

0 commit comments

Comments
 (0)