Upgrade rust/crates/unicode-bidi to 0.3.6

Test: make
Change-Id: I6c2d7917e6e929d5056dad6f9fea7e07940a35de
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 3daa8eb..54bfe61 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
 {
   "git": {
-    "sha1": "1fd2a2d8dd267f857ef18f29c8945b76c42ee19e"
+    "sha1": "2c89f8f02566cfaeb1266706b259c6c7c3aae8dd"
   }
 }
diff --git a/Android.bp b/Android.bp
index 0894381..cdef21d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -42,11 +42,13 @@
     name: "libunicode_bidi",
     host_supported: true,
     crate_name: "unicode_bidi",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.3.6",
     srcs: ["src/lib.rs"],
     edition: "2018",
-    features: ["default"],
-    rustlibs: [
-        "libmatches",
+    features: [
+        "default",
+        "std",
     ],
     apex_available: [
         "//apex_available:platform",
@@ -56,22 +58,26 @@
 }
 
 rust_defaults {
-    name: "unicode-bidi_defaults",
+    name: "unicode-bidi_test_defaults",
     crate_name: "unicode_bidi",
     srcs: ["src/lib.rs"],
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.3.6",
     test_suites: ["general-tests"],
     auto_gen_config: true,
     edition: "2018",
-    features: ["default"],
+    features: [
+        "default",
+        "std",
+    ],
     rustlibs: [
-        "libmatches",
         "libserde_test",
     ],
 }
 
 rust_test_host {
     name: "unicode-bidi_host_test_src_lib",
-    defaults: ["unicode-bidi_defaults"],
+    defaults: ["unicode-bidi_test_defaults"],
     test_options: {
         unit_test: true,
     },
@@ -79,10 +85,5 @@
 
 rust_test {
     name: "unicode-bidi_device_test_src_lib",
-    defaults: ["unicode-bidi_defaults"],
+    defaults: ["unicode-bidi_test_defaults"],
 }
-
-// dependent_library ["feature_list"]
-//   matches-0.1.8
-//   serde-1.0.126 "default,std"
-//   serde_test-1.0.126
diff --git a/Cargo.toml b/Cargo.toml
index 9ad832a..d64220e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,13 +13,14 @@
 [package]
 edition = "2018"
 name = "unicode-bidi"
-version = "0.3.5"
+version = "0.3.6"
 authors = ["The Servo Project Developers"]
 exclude = ["benches/**", "data/**", "examples/**", "tests/**", "tools/**"]
 description = "Implementation of the Unicode Bidirectional Algorithm"
 documentation = "https://docs.rs/unicode-bidi/"
 readme = "README.md"
 keywords = ["rtl", "unicode", "text", "layout", "bidi"]
+categories = ["no-std", "encoding", "text-processing"]
 license = "MIT / Apache-2.0"
 repository = "https://github.com/servo/unicode-bidi"
 
@@ -33,20 +34,19 @@
 version = "0.4"
 optional = true
 
-[dependencies.matches]
-version = "0.1"
-
 [dependencies.serde]
 version = ">=0.8, <2.0"
 features = ["derive"]
 optional = true
+default-features = false
 [dev-dependencies.serde_test]
 version = ">=0.8, <2.0"
 
 [features]
 bench_it = []
-default = []
+default = ["std"]
 flame_it = ["flame", "flamer"]
+std = []
 unstable = []
 with_serde = ["serde"]
 [badges.appveyor]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 650aa3e..912ded6 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
 [package]
 name = "unicode-bidi"
-version = "0.3.5"
+version = "0.3.6"
 authors = ["The Servo Project Developers"]
 license = "MIT / Apache-2.0"
 description = "Implementation of the Unicode Bidirectional Algorithm"
@@ -9,6 +9,11 @@
 keywords = ["rtl", "unicode", "text", "layout", "bidi"]
 readme="README.md"
 edition = "2018"
+categories = [
+    "no-std",
+    "encoding",
+    "text-processing",
+]
 
 # No data is shipped; benches, examples and tests also depend on data.
 exclude = [
@@ -29,14 +34,16 @@
 [dependencies]
 flame = { version = "0.2", optional = true }
 flamer = { version = "0.4", optional = true }
-matches = "0.1"
-serde = { version = ">=0.8, <2.0", optional = true, features = ["derive"] }
+serde = { version = ">=0.8, <2.0", default-features = false, optional = true, features = ["derive"] }
 
 [dev-dependencies]
 serde_test = ">=0.8, <2.0"
 
 [features]
-default = []
+# Note: We don't actually use the `std` feature for anything other than making
+# doctests work. But it may come in handy in the future.
+default = ["std"]
+std = []
 unstable = []  # travis-cargo needs it
 bench_it = []
 flame_it = ["flame", "flamer"]
diff --git a/METADATA b/METADATA
index ea9ca37..4590da0 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
   }
   url {
     type: ARCHIVE
-    value: "https://static.crates.io/crates/unicode-bidi/unicode-bidi-0.3.5.crate"
+    value: "https://static.crates.io/crates/unicode-bidi/unicode-bidi-0.3.6.crate"
   }
-  version: "0.3.5"
+  version: "0.3.6"
   license_type: NOTICE
   last_upgrade_date {
     year: 2021
-    month: 5
-    day: 19
+    month: 9
+    day: 22
   }
 }
diff --git a/src/char_data/mod.rs b/src/char_data/mod.rs
index da85c84..c91bfad 100644
--- a/src/char_data/mod.rs
+++ b/src/char_data/mod.rs
@@ -13,8 +13,8 @@
 
 pub use self::tables::{BidiClass, UNICODE_VERSION};
 
-use std::cmp::Ordering::{Equal, Less, Greater};
-use std::char;
+use core::cmp::Ordering::{Equal, Less, Greater};
+use core::char;
 
 use self::tables::bidi_class_table;
 use crate::BidiClass::*;
diff --git a/src/deprecated.rs b/src/deprecated.rs
index 8bd206b..491436a 100644
--- a/src/deprecated.rs
+++ b/src/deprecated.rs
@@ -9,6 +9,8 @@
 
 //! This module holds deprecated assets only.
 
+use alloc::vec::Vec;
+
 use super::*;
 
 /// Find the level runs within a line and return them in visual order.
diff --git a/src/explicit.rs b/src/explicit.rs
index 95de505..ec39dee 100644
--- a/src/explicit.rs
+++ b/src/explicit.rs
@@ -11,7 +11,7 @@
 //!
 //! <http://www.unicode.org/reports/tr9/#Explicit_Levels_and_Directions>
 
-use matches::matches;
+use alloc::vec::Vec;
 
 use super::char_data::{BidiClass::{self, *}, is_rtl};
 use super::level::Level;
@@ -46,7 +46,10 @@
                 let last_level = stack.last().level;
 
                 // X5a-X5c: Isolate initiators get the level of the last entry on the stack.
-                let is_isolate = matches!(original_classes[i], RLI | LRI | FSI);
+                let is_isolate = match original_classes[i] {
+                    RLI | LRI | FSI => true,
+                    _ => false,
+                };
                 if is_isolate {
                     levels[i] = last_level;
                     match stack.last().status {
diff --git a/src/implicit.rs b/src/implicit.rs
index 7e43294..2bb3581 100644
--- a/src/implicit.rs
+++ b/src/implicit.rs
@@ -9,8 +9,8 @@
 
 //! 3.3.4 - 3.3.6. Resolve implicit levels and types.
 
-use std::cmp::max;
-use matches::matches;
+use core::cmp::max;
+use alloc::vec::Vec;
 
 use super::char_data::BidiClass::{self, *};
 use super::prepare::{IsolatingRunSequence, LevelRun, not_removed_by_x9, removed_by_x9};
@@ -223,5 +223,8 @@
 /// <http://www.unicode.org/reports/tr9/#NI>
 #[allow(non_snake_case)]
 fn is_NI(class: BidiClass) -> bool {
-    matches!(class, B | S | WS | ON | FSI | LRI | RLI | PDI)
+    match class {
+        B | S | WS | ON | FSI | LRI | RLI | PDI => true,
+        _ => false,
+    }
 }
diff --git a/src/level.rs b/src/level.rs
index bc74205..c1adf1f 100644
--- a/src/level.rs
+++ b/src/level.rs
@@ -13,7 +13,9 @@
 //!
 //! <http://www.unicode.org/reports/tr9/#BD2>
 
-use std::convert::{From, Into};
+use alloc::vec::Vec;
+use core::convert::{From, Into};
+use alloc::string::{String, ToString};
 
 use super::char_data::BidiClass;
 
diff --git a/src/lib.rs b/src/lib.rs
index ba3220b..09bbcfb 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -53,10 +53,24 @@
 //! ]);
 //! ```
 //!
+//! # Features
+//!
+//! - `std`: Enabled by default, but can be disabled to make `unicode_bidi`
+//!   `#![no_std]` + `alloc` compatible.
+//! - `serde`: Adds [`serde::Serialize`] and [`serde::Deserialize`]
+//!   implementations to relevant types.
+//!
 //! [tr9]: <http://www.unicode.org/reports/tr9/>
 
 #![forbid(unsafe_code)]
 
+#![no_std]
+// We need to link to std to make doc tests work on older Rust versions
+#![cfg(feature = "std")]
+extern crate std;
+#[macro_use]
+extern crate alloc;
+
 pub mod deprecated;
 pub mod format_chars;
 pub mod level;
@@ -70,10 +84,12 @@
 pub use crate::level::{Level, LTR_LEVEL, RTL_LEVEL};
 pub use crate::prepare::LevelRun;
 
-use std::borrow::Cow;
-use std::cmp::{max, min};
-use std::iter::repeat;
-use std::ops::Range;
+use alloc::borrow::Cow;
+use alloc::vec::Vec;
+use alloc::string::String;
+use core::cmp::{max, min};
+use core::iter::repeat;
+use core::ops::Range;
 
 use crate::BidiClass::*;
 use crate::format_chars as chars;
diff --git a/src/prepare.rs b/src/prepare.rs
index ccb8c0f..752087b 100644
--- a/src/prepare.rs
+++ b/src/prepare.rs
@@ -11,9 +11,9 @@
 //!
 //! <http://www.unicode.org/reports/tr9/#Preparations_for_Implicit_Processing>
 
-use std::cmp::max;
-use std::ops::Range;
-use matches::matches;
+use core::cmp::max;
+use core::ops::Range;
+use alloc::vec::Vec;
 
 use super::BidiClass::{self, *};
 use super::level::Level;
@@ -73,7 +73,7 @@
 
         sequence.push(run);
 
-        if matches!(end_class, RLI | LRI | FSI) {
+        if let RLI | LRI | FSI = end_class {
             // Resume this sequence after the isolate.
             stack.push(sequence);
         } else {
@@ -113,7 +113,7 @@
             };
 
             // Get the level of the next non-removed char after the runs.
-            let succ_level = if matches!(original_classes[end_of_seq - 1], RLI | LRI | FSI) {
+            let succ_level = if let RLI | LRI | FSI = original_classes[end_of_seq - 1] {
                 para_level
             } else {
                 match original_classes[end_of_seq..].iter().position(
@@ -163,7 +163,10 @@
 ///
 /// <http://www.unicode.org/reports/tr9/#X9>
 pub fn removed_by_x9(class: BidiClass) -> bool {
-    matches!(class, RLE | LRE | RLO | LRO | PDF | BN)
+    match class {
+        RLE | LRE | RLO | LRO | PDF | BN => true,
+        _ => false,
+    }
 }
 
 // For use as a predicate for `position` / `rposition`