We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4bfc429 commit faaace5Copy full SHA for faaace5
turbopack/crates/turbo-tasks-fs/src/rope.rs
@@ -118,8 +118,24 @@ impl Rope {
118
}
119
120
121
+impl From<Vec<u8>> for Rope {
122
+ fn from(mut bytes: Vec<u8>) -> Self {
123
+ bytes.shrink_to_fit();
124
+ let bytes: Bytes = bytes.into();
125
+ // We can't have an InnerRope which contains an empty Local section.
126
+ if bytes.is_empty() {
127
+ Default::default()
128
+ } else {
129
+ Rope {
130
+ length: bytes.len(),
131
+ data: InnerRope(Arc::from([Local(bytes)])),
132
+ }
133
134
135
+}
136
+
137
impl<T: Into<Bytes>> From<T> for Rope {
- fn from(bytes: T) -> Self {
138
+ default fn from(bytes: T) -> Self {
139
let bytes = bytes.into();
140
// We can't have an InnerRope which contains an empty Local section.
141
if bytes.is_empty() {
0 commit comments