summaryrefslogtreecommitdiff
path: root/cli/file_fetcher.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2020-09-25 08:31:17 +1000
committerGitHub <noreply@github.com>2020-09-25 08:31:17 +1000
commitc489589e2b220317609689fbb1d0aec06191c7e9 (patch)
tree43d083abad7e900ebd2c7fd84160305aa6ebc5ed /cli/file_fetcher.rs
parent7726cfb93243932a07107f67b87032adb40abdc0 (diff)
refactor: new module graph used for no check (#7621)
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