summaryrefslogtreecommitdiffstats
path: root/third_party/rust/ron/src/extensions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/ron/src/extensions.rs')
-rw-r--r--third_party/rust/ron/src/extensions.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/third_party/rust/ron/src/extensions.rs b/third_party/rust/ron/src/extensions.rs
new file mode 100644
index 0000000000..5f3906c67d
--- /dev/null
+++ b/third_party/rust/ron/src/extensions.rs
@@ -0,0 +1,26 @@
+use serde::{Deserialize, Serialize};
+
+bitflags::bitflags! {
+ #[derive(Serialize, Deserialize)]
+ pub struct Extensions: usize {
+ const UNWRAP_NEWTYPES = 0x1;
+ const IMPLICIT_SOME = 0x2;
+ }
+}
+
+impl Extensions {
+ /// Creates an extension flag from an ident.
+ pub fn from_ident(ident: &[u8]) -> Option<Extensions> {
+ match ident {
+ b"unwrap_newtypes" => Some(Extensions::UNWRAP_NEWTYPES),
+ b"implicit_some" => Some(Extensions::IMPLICIT_SOME),
+ _ => None,
+ }
+ }
+}
+
+impl Default for Extensions {
+ fn default() -> Self {
+ Extensions::empty()
+ }
+}