From 3823fc0e745b1fe076aacc2b6e9fcb40f597cc8a Mon Sep 17 00:00:00 2001 From: Zengor Date: Thu, 21 Sep 2017 00:24:47 -0300 Subject: [PATCH] Call playground with /execute and not the legacy /evaluate.json This commit changes the url used to call the playground, and the request parameter format to go with it. The older evaluate is available in the playground as a form of backwards compatibility and swithcing now opens way for using newer features. --- src/theme/book.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/theme/book.js b/src/theme/book.js index d7f0e690..bbbd6b54 100644 --- a/src/theme/book.js +++ b/src/theme/book.js @@ -358,22 +358,24 @@ function run_rust_code(code_block) { result_block = code_block.find(".result"); } - let text = playpen_text(code_block);; - + let text = playpen_text(code_block); + var params = { - version: "stable", - optimize: "0", - code: text, - }; + channel: "stable", + mode: "debug", + crateType: "bin", + tests: false, + code: text, + } if(text.indexOf("#![feature") !== -1) { - params.version = "nightly"; + params.channel = "nightly"; } result_block.text("Running..."); $.ajax({ - url: "https://play.rust-lang.org/evaluate.json", + url: "https://play.rust-lang.org/execute", method: "POST", crossDomain: true, dataType: "json", @@ -381,7 +383,7 @@ function run_rust_code(code_block) { data: JSON.stringify(params), timeout: 15000, success: function(response){ - result_block.text(response.result); + result_block.text(response.success ? response.stdout : response.stderr); }, error: function(qXHR, textStatus, errorThrown){ result_block.text("Playground communication " + textStatus);