manifest-schema: Improve quality as a library

This commit is contained in:
Taiki Endo
2025-01-28 16:36:10 +09:00
parent 22b428f64c
commit 5ad07d35ce
3 changed files with 81 additions and 7 deletions

View File

@@ -2,16 +2,33 @@
name = "install-action-manifest-schema"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"
rust-version = "1.79" # Align to cargo-binstall: https://crates.io/crates/cargo-binstall
license = "Apache-2.0 OR MIT"
repository = "https://github.com/taiki-e/install-action"
keywords = []
categories = []
description = """
Structured access to the install-action manifests.
"""
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[package.metadata.cargo_check_external_types]
# The following are external types that are allowed to be exposed in our public API.
allowed_external_types = [
"semver::*",
"serde::*",
]
[lib]
doc-scrape-examples = false
# Note: semver and serde are public dependencies.
[dependencies]
semver = { version = "1", features = ["serde"] }
serde = "1"
serde_derive = "1"
serde = "1.0.165"
serde_derive = "1.0.165"
[lints]
workspace = true
[package.metadata.cargo_check_external_types]
allowed_external_types = ["semver::*", "serde::*"]

View File

@@ -1,5 +1,28 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
/*!
Structured access to the install-action manifests.
*/
#![doc(test(
no_crate_inject,
attr(
deny(warnings, rust_2018_idioms, single_use_lifetimes),
allow(dead_code, unused_variables)
)
))]
#![warn(
// Lints that may help when writing public library.
missing_debug_implementations,
// missing_docs,
clippy::alloc_instead_of_core,
// clippy::exhaustive_enums,
// clippy::exhaustive_structs,
clippy::impl_trait_in_params,
// clippy::missing_inline_in_public_items,
// clippy::std_instead_of_alloc,
// clippy::std_instead_of_core,
)]
#![allow(clippy::missing_panics_doc, clippy::too_long_first_doc_paragraph)]
use std::{
@@ -303,7 +326,7 @@ impl StringOrArray {
}
}
#[must_use]
pub fn map(&self, mut f: impl FnMut(&String) -> String) -> Self {
pub fn map<F: FnMut(&String) -> String>(&self, mut f: F) -> Self {
match self {
Self::String(s) => Self::String(f(s)),
Self::Array(v) => Self::Array(v.iter().map(f).collect()),