@@ -434,37 +434,12 @@ impl Drop for Blocker<'_> {
434434 }
435435}
436436
437- // // / Custom display trait to bypass orphan rules.
438- // // / Implemented on [`Option<_>`] to default to printing nothing.
437+ /// Custom display trait to bypass orphan rules.
438+ /// Implemented on [`Option<_>`] to default to printing nothing.
439439pub trait DisplayExt {
440440 fn display ( self ) -> impl Display ;
441441}
442442
443- // impl<T: Display> DisplayExt for Option<T> {
444- // fn display(&self) -> impl Display {
445- // #[repr(transparent)]
446- // struct OptionDisplay<'a, T>(Option<&'a T>);
447- // impl<T: Display> Display for OptionDisplay<'_, T> {
448- // #[inline]
449- // fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> std::fmt::Result {
450- // match &self.0 {
451- // Some(value) => value.fmt(f),
452- // None => Ok(()),
453- // }
454- // }
455- // }
456- // OptionDisplay(self.as_ref())
457- // }
458- // }
459-
460- // impl<T: Display> DisplayExt for Option<&T> {
461- // fn display(self) -> impl Display {
462- // match self {
463- // Some(value) => value as &dyn Display,
464- // None => &"" as &dyn Display,
465- // }
466- // }
467- // }
468443impl < T : Display > DisplayExt for Option < T > {
469444 fn display ( self ) -> impl Display {
470445 struct Adapter < T > ( Option < T > ) ;
@@ -631,13 +606,12 @@ pub fn strict_canonicalize<P: AsRef<Path>>(path: P) -> anyhow::Result<PathBuf> {
631606
632607#[ cfg( test) ]
633608mod tests {
634- use std:: { path:: Path , str :: FromStr } ;
609+ use std:: path:: Path ;
635610
636611 use crate :: utils:: { strict_canonicalize, DisplayExt } ;
637612
638613 use super :: { to_display_path, uri_from_file_path, UriExt , WSL } ;
639614 use pretty_assertions:: assert_eq;
640- use tower_lsp_server:: lsp_types:: Uri ;
641615
642616 #[ test]
643617 fn test_to_display_path ( ) {
@@ -668,6 +642,9 @@ mod tests {
668642 #[ test]
669643 #[ cfg( windows) ]
670644 fn test_windows_uri_roundtrip_conversion ( ) {
645+ use std:: str:: FromStr ;
646+ use tower_lsp_server:: lsp_types:: Uri ;
647+
671648 let uri = Uri :: from_str ( "file:///C:/Windows" ) . unwrap ( ) ;
672649 let path = uri. to_file_path ( ) . unwrap ( ) ;
673650 assert_eq ! ( & path, Path :: new( "C:/Windows" ) , "uri={uri:?}" ) ;
0 commit comments