+/// Describes the way the content of the `rendered` field of the json output is generated
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum HumanReadableErrorType {
+ Default(ColorConfig),
+ Short(ColorConfig),
+}
+
+impl HumanReadableErrorType {
+ /// Returns a (`short`, `color`) tuple
+ pub fn unzip(self) -> (bool, ColorConfig) {
+ match self {
+ HumanReadableErrorType::Default(cc) => (false, cc),
+ HumanReadableErrorType::Short(cc) => (true, cc),
+ }
+ }
+ pub fn new_emitter(
+ self,
+ dst: Box<dyn Write + Send>,
+ source_map: Option<Lrc<SourceMapperDyn>>,
+ teach: bool,
+ ) -> EmitterWriter {
+ let (short, color_config) = self.unzip();
+ EmitterWriter::new(dst, source_map, short, teach, color_config.suggests_using_colors())
+ }
+}
+