File tree Expand file tree Collapse file tree 4 files changed +30
-41
lines changed Expand file tree Collapse file tree 4 files changed +30
-41
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ module.exports = {
96
96
'reducers/selection.ts' ,
97
97
'reducers/versions.ts' ,
98
98
'reducers/websocket.ts' ,
99
+ 'types.ts' ,
99
100
'websocketActions.ts' ,
100
101
'websocketMiddleware.ts' ,
101
102
] ,
Original file line number Diff line number Diff line change @@ -47,5 +47,6 @@ node_modules
47
47
! reducers /selection.ts
48
48
! reducers /versions.ts
49
49
! reducers /websocket.ts
50
+ ! types.ts
50
51
! websocketActions.ts
51
52
! websocketMiddleware.ts
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ import {
14
14
PrimaryAction ,
15
15
PrimaryActionAuto ,
16
16
PrimaryActionCore ,
17
+ parseChannel ,
18
+ parseEdition ,
19
+ parseMode ,
17
20
} from './types' ;
18
21
19
22
import { performCommonExecute , wsExecuteRequest } from './reducers/output/execute' ;
@@ -125,45 +128,6 @@ export const performCompileToNightlyHir =
125
128
export const performCompileToWasm =
126
129
performAndSwitchPrimaryAction ( performCompileToCdylibWasmOnly , PrimaryActionCore . Wasm ) ;
127
130
128
- function parseChannel ( s ?: string ) : Channel | null {
129
- switch ( s ) {
130
- case 'stable' :
131
- return Channel . Stable ;
132
- case 'beta' :
133
- return Channel . Beta ;
134
- case 'nightly' :
135
- return Channel . Nightly ;
136
- default :
137
- return null ;
138
- }
139
- }
140
-
141
- function parseMode ( s ?: string ) : Mode | null {
142
- switch ( s ) {
143
- case 'debug' :
144
- return Mode . Debug ;
145
- case 'release' :
146
- return Mode . Release ;
147
- default :
148
- return null ;
149
- }
150
- }
151
-
152
- function parseEdition ( s ?: string ) : Edition | null {
153
- switch ( s ) {
154
- case '2015' :
155
- return Edition . Rust2015 ;
156
- case '2018' :
157
- return Edition . Rust2018 ;
158
- case '2021' :
159
- return Edition . Rust2021 ;
160
- case '2024' :
161
- return Edition . Rust2024 ;
162
- default :
163
- return null ;
164
- }
165
- }
166
-
167
131
export function indexPageLoad ( {
168
132
code,
169
133
gist,
Original file line number Diff line number Diff line change @@ -7,8 +7,10 @@ export interface Position {
7
7
column : number ;
8
8
}
9
9
10
- export const makePosition = ( line : string | number , column : string | number ) : Position =>
11
- ( { line : + line , column : + column } ) ;
10
+ export const makePosition = ( line : string | number , column : string | number ) : Position => ( {
11
+ line : + line ,
12
+ column : + column ,
13
+ } ) ;
12
14
13
15
export interface Selection {
14
16
start ?: Position ;
@@ -104,18 +106,39 @@ export enum Channel {
104
106
Nightly = 'nightly' ,
105
107
}
106
108
109
+ const ChannelEnum = z . nativeEnum ( Channel ) ;
110
+
111
+ export function parseChannel ( s ?: string ) : Channel | null {
112
+ const p = ChannelEnum . safeParse ( s ) ;
113
+ return p . success ? p . data : null ;
114
+ }
115
+
107
116
export enum Mode {
108
117
Debug = 'debug' ,
109
118
Release = 'release' ,
110
119
}
111
120
121
+ const ModeEnum = z . nativeEnum ( Mode ) ;
122
+
123
+ export function parseMode ( s ?: string ) : Mode | null {
124
+ const p = ModeEnum . safeParse ( s ) ;
125
+ return p . success ? p . data : null ;
126
+ }
127
+
112
128
export enum Edition {
113
129
Rust2015 = '2015' ,
114
130
Rust2018 = '2018' ,
115
131
Rust2021 = '2021' ,
116
132
Rust2024 = '2024' ,
117
133
}
118
134
135
+ const EditionEnum = z . nativeEnum ( Edition ) ;
136
+
137
+ export function parseEdition ( s ?: string ) : Edition | null {
138
+ const p = EditionEnum . safeParse ( s ) ;
139
+ return p . success ? p . data : null ;
140
+ }
141
+
119
142
export enum Backtrace {
120
143
Disabled = 'disabled' ,
121
144
Enabled = 'enabled' ,
You can’t perform that action at this time.
0 commit comments