]> Repositorios git - scryer-prolog.git/commitdiff
improve comment
authorSkgland <[email protected]>
Thu, 11 Mar 2021 00:18:11 +0000 (01:18 +0100)
committerSkgland <[email protected]>
Thu, 11 Mar 2021 00:52:21 +0000 (01:52 +0100)
src/machine/streams.rs

index e1401b0ed983583bf53de50287d8685bac8f4097..97c3b494b916c82b03a722a80734bd8cf5c7e3f9 100644 (file)
@@ -365,7 +365,17 @@ impl Stream {
     }
 
     pub fn bytes(&self) -> Option<std::cell::Ref<Vec<u8>>> {
-        // if Ref had an and_then function this could be simplified
+        /*
+        // Replacement of workaround for when we have stable https://github.com/rust-lang/rust/issues/81061
+        std::cell::Ref::filter_map(
+            self.stream_inst.0.borrow(),
+            |inner_stream| match inner_stream.stream_inst {
+                StreamInstance::Bytes(cursor) => Some(cursor.get_ref()),
+                _ => None,
+            },
+        )
+        .ok()
+        */
         let val = std::cell::Ref::map(self.stream_inst.0.borrow(), |inner_stream| {
             &inner_stream.stream_inst
         });