@@ -44,36 +44,45 @@ use std::{
4444/// Core structured values that pass through the pipeline in Nushell.
4545// NOTE: Please do not reorder these enum cases without thinking through the
4646// impact on the PartialOrd implementation and the global sort order
47+ // NOTE: All variants are marked as `non_exhaustive` to prevent them
48+ // from being constructed (outside of this crate) with the struct
49+ // expression syntax. This makes using the constructor methods the
50+ // only way to construct `Value`'s
4751#[ derive( Debug , Serialize , Deserialize ) ]
4852pub enum Value {
53+ #[ non_exhaustive]
4954 Bool {
5055 val : bool ,
5156 /// note: spans are being refactored out of Value
5257 /// please use .span() instead of matching this span value
5358 #[ serde( rename = "span" ) ]
5459 internal_span : Span ,
5560 } ,
61+ #[ non_exhaustive]
5662 Int {
5763 val : i64 ,
5864 /// note: spans are being refactored out of Value
5965 /// please use .span() instead of matching this span value
6066 #[ serde( rename = "span" ) ]
6167 internal_span : Span ,
6268 } ,
69+ #[ non_exhaustive]
6370 Float {
6471 val : f64 ,
6572 /// note: spans are being refactored out of Value
6673 /// please use .span() instead of matching this span value
6774 #[ serde( rename = "span" ) ]
6875 internal_span : Span ,
6976 } ,
77+ #[ non_exhaustive]
7078 String {
7179 val : String ,
7280 /// note: spans are being refactored out of Value
7381 /// please use .span() instead of matching this span value
7482 #[ serde( rename = "span" ) ]
7583 internal_span : Span ,
7684 } ,
85+ #[ non_exhaustive]
7786 Glob {
7887 val : String ,
7988 no_expand : bool ,
@@ -82,13 +91,15 @@ pub enum Value {
8291 #[ serde( rename = "span" ) ]
8392 internal_span : Span ,
8493 } ,
94+ #[ non_exhaustive]
8595 Filesize {
8696 val : Filesize ,
8797 /// note: spans are being refactored out of Value
8898 /// please use .span() instead of matching this span value
8999 #[ serde( rename = "span" ) ]
90100 internal_span : Span ,
91101 } ,
102+ #[ non_exhaustive]
92103 Duration {
93104 /// The duration in nanoseconds.
94105 val : i64 ,
@@ -97,69 +108,79 @@ pub enum Value {
97108 #[ serde( rename = "span" ) ]
98109 internal_span : Span ,
99110 } ,
111+ #[ non_exhaustive]
100112 Date {
101113 val : DateTime < FixedOffset > ,
102114 /// note: spans are being refactored out of Value
103115 /// please use .span() instead of matching this span value
104116 #[ serde( rename = "span" ) ]
105117 internal_span : Span ,
106118 } ,
119+ #[ non_exhaustive]
107120 Range {
108121 val : Box < Range > ,
109122 /// note: spans are being refactored out of Value
110123 /// please use .span() instead of matching this span value
111124 #[ serde( rename = "span" ) ]
112125 internal_span : Span ,
113126 } ,
127+ #[ non_exhaustive]
114128 Record {
115129 val : SharedCow < Record > ,
116130 /// note: spans are being refactored out of Value
117131 /// please use .span() instead of matching this span value
118132 #[ serde( rename = "span" ) ]
119133 internal_span : Span ,
120134 } ,
135+ #[ non_exhaustive]
121136 List {
122137 vals : Vec < Value > ,
123138 /// note: spans are being refactored out of Value
124139 /// please use .span() instead of matching this span value
125140 #[ serde( rename = "span" ) ]
126141 internal_span : Span ,
127142 } ,
143+ #[ non_exhaustive]
128144 Closure {
129145 val : Box < Closure > ,
130146 /// note: spans are being refactored out of Value
131147 /// please use .span() instead of matching this span value
132148 #[ serde( rename = "span" ) ]
133149 internal_span : Span ,
134150 } ,
151+ #[ non_exhaustive]
135152 Error {
136153 error : Box < ShellError > ,
137154 /// note: spans are being refactored out of Value
138155 /// please use .span() instead of matching this span value
139156 #[ serde( rename = "span" ) ]
140157 internal_span : Span ,
141158 } ,
159+ #[ non_exhaustive]
142160 Binary {
143161 val : Vec < u8 > ,
144162 /// note: spans are being refactored out of Value
145163 /// please use .span() instead of matching this span value
146164 #[ serde( rename = "span" ) ]
147165 internal_span : Span ,
148166 } ,
167+ #[ non_exhaustive]
149168 CellPath {
150169 val : CellPath ,
151170 /// note: spans are being refactored out of Value
152171 /// please use .span() instead of matching this span value
153172 #[ serde( rename = "span" ) ]
154173 internal_span : Span ,
155174 } ,
175+ #[ non_exhaustive]
156176 Custom {
157177 val : Box < dyn CustomValue > ,
158178 /// note: spans are being refactored out of Value
159179 /// please use .span() instead of matching this span value
160180 #[ serde( rename = "span" ) ]
161181 internal_span : Span ,
162182 } ,
183+ #[ non_exhaustive]
163184 Nothing {
164185 /// note: spans are being refactored out of Value
165186 /// please use .span() instead of matching this span value
0 commit comments