Merge pull request #938 from kamalmarhubi/rename-doc-hint
config: Rename get_variant_names to doc_hint
This commit is contained in:
commit
ebebe96aab
@ -153,26 +153,27 @@ pub fn to_list_tactic(self) -> ListTactic {
|
||||
Checkstyle,
|
||||
}
|
||||
|
||||
// This trait and the following impl blocks are there so that we an use
|
||||
// UCFS inside the get_docs() function on types for configs.
|
||||
pub trait ConfigType {
|
||||
fn get_variant_names() -> String;
|
||||
/// Trait for types that can be used in `Config`.
|
||||
pub trait ConfigType: Sized {
|
||||
/// Returns hint text for use in `Config::print_docs()`. For enum types, this is a
|
||||
/// pipe-separated list of variants; for other types it returns "<type>".
|
||||
fn doc_hint() -> String;
|
||||
}
|
||||
|
||||
impl ConfigType for bool {
|
||||
fn get_variant_names() -> String {
|
||||
fn doc_hint() -> String {
|
||||
String::from("<boolean>")
|
||||
}
|
||||
}
|
||||
|
||||
impl ConfigType for usize {
|
||||
fn get_variant_names() -> String {
|
||||
fn doc_hint() -> String {
|
||||
String::from("<unsigned integer>")
|
||||
}
|
||||
}
|
||||
|
||||
impl ConfigType for String {
|
||||
fn get_variant_names() -> String {
|
||||
fn doc_hint() -> String {
|
||||
String::from("<string>")
|
||||
}
|
||||
}
|
||||
@ -278,7 +279,7 @@ pub fn print_docs() {
|
||||
name_out.push(' ');
|
||||
println!("{}{} Default: {:?}",
|
||||
name_out,
|
||||
<$ty>::get_variant_names(),
|
||||
<$ty>::doc_hint(),
|
||||
$def);
|
||||
$(
|
||||
println!("{}{}", space_str, $dstring);
|
||||
|
@ -219,7 +219,7 @@ fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
}
|
||||
|
||||
impl ::config::ConfigType for $e {
|
||||
fn get_variant_names() -> String {
|
||||
fn doc_hint() -> String {
|
||||
let mut variants = Vec::new();
|
||||
$(
|
||||
variants.push(stringify!($x));
|
||||
|
Loading…
Reference in New Issue
Block a user