Created
December 13, 2022 21:22
-
-
Save piksel/698569df54626c02da604da88c8c287d to your computer and use it in GitHub Desktop.
rust vs go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (MarkdownTreeRenderer) writeFieldExtras(sb *strings.Builder, field *FieldInfo) { | |
if len(field.Keys) > 1 { | |
sb.WriteString(" Aliases: `") | |
for i, key := range field.Keys { | |
if i == 0 { | |
// Skip primary alias (as it's the same as the field name) | |
continue | |
} | |
if i > 1 { | |
sb.WriteString("`, `") | |
} | |
sb.WriteString(key) | |
} | |
sb.WriteString("` \n") | |
} | |
if field.EnumFormatter != nil { | |
sb.WriteString(" Possible values: `") | |
for i, name := range field.EnumFormatter.Names() { | |
if i != 0 { | |
sb.WriteString("`, `") | |
} | |
sb.WriteString(name) | |
} | |
sb.WriteString("` \n") | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn write_field_extras(&self, output: &mut String, prop: &spec::SpecProp) -> eyre::Result<()> { | |
// Skip primary alias (as it's the same as the field name) | |
if let Some((_, rest)) = prop.keys.split_first() { | |
writeln!(output, " Aliases: `{}` ", rest.join("`,`"))?; | |
} | |
if let PropType::Option(opt) = prop.prop_type { | |
writeln!(output, " Possible values: `{}` ", opt.values.join("`,`"))?; | |
} | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment