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 @@ configuration_option_enum! { WriteMode:
|
|||||||
Checkstyle,
|
Checkstyle,
|
||||||
}
|
}
|
||||||
|
|
||||||
// This trait and the following impl blocks are there so that we an use
|
/// Trait for types that can be used in `Config`.
|
||||||
// UCFS inside the get_docs() function on types for configs.
|
pub trait ConfigType: Sized {
|
||||||
pub trait ConfigType {
|
/// Returns hint text for use in `Config::print_docs()`. For enum types, this is a
|
||||||
fn get_variant_names() -> String;
|
/// pipe-separated list of variants; for other types it returns "<type>".
|
||||||
|
fn doc_hint() -> String;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConfigType for bool {
|
impl ConfigType for bool {
|
||||||
fn get_variant_names() -> String {
|
fn doc_hint() -> String {
|
||||||
String::from("<boolean>")
|
String::from("<boolean>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConfigType for usize {
|
impl ConfigType for usize {
|
||||||
fn get_variant_names() -> String {
|
fn doc_hint() -> String {
|
||||||
String::from("<unsigned integer>")
|
String::from("<unsigned integer>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConfigType for String {
|
impl ConfigType for String {
|
||||||
fn get_variant_names() -> String {
|
fn doc_hint() -> String {
|
||||||
String::from("<string>")
|
String::from("<string>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -278,7 +279,7 @@ macro_rules! create_config {
|
|||||||
name_out.push(' ');
|
name_out.push(' ');
|
||||||
println!("{}{} Default: {:?}",
|
println!("{}{} Default: {:?}",
|
||||||
name_out,
|
name_out,
|
||||||
<$ty>::get_variant_names(),
|
<$ty>::doc_hint(),
|
||||||
$def);
|
$def);
|
||||||
$(
|
$(
|
||||||
println!("{}{}", space_str, $dstring);
|
println!("{}{}", space_str, $dstring);
|
||||||
|
@ -219,7 +219,7 @@ macro_rules! impl_enum_decodable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ::config::ConfigType for $e {
|
impl ::config::ConfigType for $e {
|
||||||
fn get_variant_names() -> String {
|
fn doc_hint() -> String {
|
||||||
let mut variants = Vec::new();
|
let mut variants = Vec::new();
|
||||||
$(
|
$(
|
||||||
variants.push(stringify!($x));
|
variants.push(stringify!($x));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user