{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%load_ext rust_magic" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "4\n" ] } ], "source": [ "%rust 2+2" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(2, 10)\n" ] } ], "source": [ "%%rust\n", "let mut a = (2, 3);\n", "a.1 = 10;\n", "a" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Hi, Rust!\n" ] } ], "source": [ "%%rust\n", "fn main() {\n", " println!(\"Hi, Rust!\");\n", "}" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "'//! ```cargo\\n//! [dependencies]\\n//! time = \"0.1.42\"\\n//! ```\\nextern crate time;\\n\\nprintln!(\"{}\", time::now().rfc822z());\\n'\n", "Thu, 22 Aug 2019 12:17:11 +0700\n" ] } ], "source": [ "%%rust\n", "//! ```cargo\n", "//! [dependencies]\n", "//! time = \"0.1.42\"\n", "//! ```\n", "extern crate time;\n", "\n", "println!(\"{}\", time::now().rfc822z());" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "thread 'main' panicked at 'attempt to add with overflow', cell.rs:4:1\n", "note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.\n" ] } ], "source": [ "%%rust --debug\n", "let a: u8 = 255;\n", "a + 1" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.2" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }