review(p6-1): 회차 3 cosmetic 정리
- src/dims.rs: `with_guessed_format()` 의 `map_err(...)` 를 `.context()?` 로 정리. 회차 2 의 `match Some/None` → `.context()?` 정리와 호출 스타일 통일. - src/lib.rs: `(*format).to_string()` → `format.to_string()`. `format` 이 `&&'static str` 이라 명시 deref 없이 자동 호출 가능. - tests/common/mod.rs: `ImageFixture::workspace_root` / `config` 가시성을 `pub` → 모듈-비공개로 축소. 외부 호출자가 두 필드를 직접 읽지 않고 `ctx()` 만 사용함. cargo test -p kebab-parse-image — 16건 pass. cargo clippy -p kebab-parse-image --all-targets -- -D warnings — pass.
This commit is contained in:
@@ -35,7 +35,7 @@ pub(crate) enum DimOutcome {
|
||||
pub(crate) fn probe(bytes: &[u8]) -> Result<DimOutcome> {
|
||||
let reader = ImageReader::new(Cursor::new(bytes))
|
||||
.with_guessed_format()
|
||||
.map_err(|e| anyhow::anyhow!("io error guessing format: {e}"))?;
|
||||
.context("reading image header")?;
|
||||
|
||||
let format = reader
|
||||
.format()
|
||||
|
||||
@@ -85,7 +85,7 @@ impl Extractor for ImageExtractor {
|
||||
let mut dims = Map::new();
|
||||
dims.insert("w".into(), Value::Number((*width).into()));
|
||||
dims.insert("h".into(), Value::Number((*height).into()));
|
||||
dims.insert("format".into(), Value::String((*format).to_string()));
|
||||
dims.insert("format".into(), Value::String(format.to_string()));
|
||||
(
|
||||
SourceSpan::Region {
|
||||
x: 0,
|
||||
|
||||
@@ -210,8 +210,8 @@ pub fn corrupt_png() -> Vec<u8> {
|
||||
/// per §4.2 — this matches what `kebab-source-fs` does in production.
|
||||
pub struct ImageFixture {
|
||||
pub asset: RawAsset,
|
||||
pub workspace_root: PathBuf,
|
||||
pub config: ExtractConfig,
|
||||
workspace_root: PathBuf,
|
||||
config: ExtractConfig,
|
||||
}
|
||||
|
||||
impl ImageFixture {
|
||||
|
||||
Reference in New Issue
Block a user