summaryrefslogtreecommitdiff
path: root/cli/file_fetcher.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/file_fetcher.rs')
-rw-r--r--cli/file_fetcher.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs
index af4aef07a..6678a393d 100644
--- a/cli/file_fetcher.rs
+++ b/cli/file_fetcher.rs
@@ -33,7 +33,7 @@ use std::sync::Arc;
use std::sync::Mutex;
/// Structure representing a text document.
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Eq, PartialEq)]
pub struct TextDocument {
bytes: Vec<u8>,
charset: Cow<'static, str>,
@@ -73,6 +73,18 @@ impl From<Vec<u8>> for TextDocument {
}
}
+impl From<String> for TextDocument {
+ fn from(s: String) -> Self {
+ TextDocument::new(s.as_bytes().to_vec(), Option::<&str>::None)
+ }
+}
+
+impl From<&str> for TextDocument {
+ fn from(s: &str) -> Self {
+ TextDocument::new(s.as_bytes().to_vec(), Option::<&str>::None)
+ }
+}
+
/// Structure representing local or remote file.
///
/// In case of remote file `url` might be different than originally requested URL, if so