@@ -78,7 +78,7 @@ pub struct InteractivePrinter<'a> {
7878 decorations: Vec<Box<dyn Decoration>>,
7979 panel_width: usize,
8080 ansi_prefix_sgr: String,
81− content_type: ContentType,
81+ content_type: Option<ContentType>,
8282 pub line_changes: Option<LineChanges>,
8383 highlighter: Option<HighlightLines<'a>>,
8484 syntax_set: &'a SyntaxSet,
@@ -134,7 +134,7 @@ impl<'a> InteractivePrinter<'a> {
134134
135135 let mut line_changes = None;
136136
137− let highlighter = if reader.content_type.is_binary() {
137+ let highlighter = if reader.content_type.map_or(false, |c| c.is_binary()) {
138138 None
139139 } else {
140140 // Get the Git modifications
@@ -194,7 +194,7 @@ impl<'a> InteractivePrinter<'a> {
194194impl<'a> Printer for InteractivePrinter<'a> {
195195 fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()> {
196196 if !self.config.output_components.header() {
197− if ContentType::BINARY == self.content_type {
197+ if Some(ContentType::BINARY) == self.content_type {
198198 let input = match file {
199199 InputFile::Ordinary(filename) => format!("file '{}'", filename),
200200 _ => "STDIN".into(),
@@ -232,9 +232,10 @@ impl<'a> Printer for InteractivePrinter<'a> {
232232 };
233233
234234 let mode = match self.content_type {
235− ContentType::BINARY => " <BINARY>",
236− ContentType::UTF_16LE => " <UTF-16LE>",
237− ContentType::UTF_16BE => " <UTF-16BE>",
235+ Some(ContentType::BINARY) => " <BINARY>",
236+ Some(ContentType::UTF_16LE) => " <UTF-16LE>",
237+ Some(ContentType::UTF_16BE) => " <UTF-16BE>",
238+ None => " <EMPTY>",
238239 _ => "",
239240 };
240241
@@ -247,7 +248,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
247248 )?;
248249
249250 if self.config.output_components.grid() {
250− if self.content_type.is_text() {
251+ if self.content_type.map_or(false, |c| c.is_text()) {
251252 self.print_horizontal_line(handle, '┼')?;
252253 } else {
253254 self.print_horizontal_line(handle, '┴')?;
@@ -258,7 +259,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
258259 }
259260
260261 fn print_footer(&mut self, handle: &mut Write) -> Result<()> {
261− if self.config.output_components.grid() && self.content_type.is_text() {
262+ if self.config.output_components.grid() && self.content_type.map_or(false, |c| c.is_text())
263+ {
262264 self.print_horizontal_line(handle, '┴')
263265 } else {
264266 Ok(())
@@ -273,13 +275,13 @@ impl<'a> Printer for InteractivePrinter<'a> {
273275 line_buffer: &[u8],
274276 ) -> Result<()> {
275277 let mut line = match self.content_type {
276− ContentType::BINARY => {
278+ Some(ContentType::BINARY) | None => {
277279 return Ok(());
278280 }
279− ContentType::UTF_16LE => UTF_16LE
281+ Some(ContentType::UTF_16LE) => UTF_16LE
280282 .decode(&line_buffer, DecoderTrap::Replace)
281283 .map_err(|_| "Invalid UTF-16LE")?,
282− ContentType::UTF_16BE => UTF_16BE
284+ Some(ContentType::UTF_16BE) => UTF_16BE
283285 .decode(&line_buffer, DecoderTrap::Replace)
284286 .map_err(|_| "Invalid UTF-16BE")?,
285287 _ => String::from_utf8_lossy(&line_buffer).to_string(),