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 = {
9696 'reducers/selection.ts' ,
9797 'reducers/versions.ts' ,
9898 'reducers/websocket.ts' ,
99+ 'types.ts' ,
99100 'websocketActions.ts' ,
100101 'websocketMiddleware.ts' ,
101102 ] ,
Original file line number Diff line number Diff line change @@ -47,5 +47,6 @@ node_modules
4747! reducers /selection.ts
4848! reducers /versions.ts
4949! reducers /websocket.ts
50+ ! types.ts
5051! websocketActions.ts
5152! websocketMiddleware.ts
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ import {
1414 PrimaryAction ,
1515 PrimaryActionAuto ,
1616 PrimaryActionCore ,
17+ parseChannel ,
18+ parseEdition ,
19+ parseMode ,
1720} from './types' ;
1821
1922import { performCommonExecute , wsExecuteRequest } from './reducers/output/execute' ;
@@ -125,45 +128,6 @@ export const performCompileToNightlyHir =
125128export const performCompileToWasm =
126129 performAndSwitchPrimaryAction ( performCompileToCdylibWasmOnly , PrimaryActionCore . Wasm ) ;
127130
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-
167131export function indexPageLoad ( {
168132 code,
169133 gist,
Original file line number Diff line number Diff line change @@ -7,8 +7,10 @@ export interface Position {
77 column : number ;
88}
99
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+ } ) ;
1214
1315export interface Selection {
1416 start ?: Position ;
@@ -104,18 +106,39 @@ export enum Channel {
104106 Nightly = 'nightly' ,
105107}
106108
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+
107116export enum Mode {
108117 Debug = 'debug' ,
109118 Release = 'release' ,
110119}
111120
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+
112128export enum Edition {
113129 Rust2015 = '2015' ,
114130 Rust2018 = '2018' ,
115131 Rust2021 = '2021' ,
116132 Rust2024 = '2024' ,
117133}
118134
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+
119142export enum Backtrace {
120143 Disabled = 'disabled' ,
121144 Enabled = 'enabled' ,
You can’t perform that action at this time.
0 commit comments