akiomik / akiomik/nostui

AppConfig holds two directories nothing reads

未關閉
#581 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
enhancement
主要語言
Rust
星號
71
分支
5
平均合併
4 小時 2 分鐘
30 天內合併 PR
31

描述

Raised while reviewing [#576](https://github.com/akiomik/nostui/pull/576), which has to work around these rather than use them.

## What they are

```rust
#[derive(Clone, Debug, Deserialize, Default)]
pub struct AppConfig {
#[serde(default)]
pub _data_dir: PathBuf,
#[serde(default)]
pub _config_dir: PathBuf,
}
```

`Config::new` fills them with `set_default("_data_dir", …)` and `set_default("_config_dir", …)`, and nothing reads them back — `grep` over the tree finds the declaration and those two calls and nothing else. `config` has no interpolation either, so a user's own file can override them and still nobody is looking.

They are the whole of `AppConfig`, which `Config` flattens.

## Why it came up

The paths have to become strings to be set as defaults, and `Config::new` used to refuse to start when one of them was not UTF-8. #576 made `get_config_dir` answer with an absolute path, which brought the working directory's bytes into that question and turned a readable configuration in a directory with an unusual name into a refusal to start — so the conversion is lossy now, over values nobody consumes.

Deleting the fields settles it better than the comment explaining the lossiness does: there is nothing to convert, so nothing to be lossy or strict about.

## What it costs

They are `pub` on a `pub` type of a published crate, and removing them empties `AppConfig`, so the question is really whether that type should exist. The same reasoning as [#572](https://github.com/akiomik/nostui/issues/572) applies — this crate's lib surface is the inside of a TUI binary — but this is a type rather than a method, and `Config` flattens it, so it wants looking at as a shape rather than as a deletion.

## Acceptance

- Nothing in `Config::new` converts a directory to a string in order to throw it away.
- Whatever remains of `AppConfig` is read by something, or is gone.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。