Skip to main content

rust-magic Build Status

Allows to try rust in Jupyter notebook. Implemented via line/cell magics:

Installation

  1. Install rust and jupyter-notebook

  2. cargo install cargo-script

  3. pip install rust-magic

  4. Enjoy :)

Third-party crates

are supported via normal cargo script syntax (see below for a more compact notation):

Compiler options

can be provided in the cell mode:

NB Here's a copy-pastable form of all the examples above.

Syntax highlighting

To enable rust syntax highlighting in %%rust cells run the following snippet in a python jupyter cell:

from notebook.services.config import ConfigManager
c = ConfigManager()
c.update('notebook', {"CodeCell": {"highlight_modes": {"text/x-rustsrc": {"reg": ["^%%rust"]}}}})

This only needs to be run once: it stores the setting in a config file in home directory.

Long cells

Jupyter "doesn't like" long cells: when a cell gets longer than the screen its output is not readily visible. Here're a few ways how to handle the problem with rust_magic:

a) putting dependencies into a separate cell (more)

b) collapsing function bodies with codefolding jupyter extension

c) putting function definitions into separate cells (more)

Faster compile times

can be acheived by caching dependencies compile results with sccache. Rust-magic automatically uses it if it is installed in the system (cargo install sccache).

Release files for rust-magic 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rust-magic 0.3.3
File Size Uploaded
rust_magic-0.3.3.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rust-magic 0.3.3
File Interpreter ABI Platform
rust_magic-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 15.1 kB

Release files / rust_magic-0.3.3.tar.gz

Download URL rust_magic-0.3.3.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
926dfa2db275afe7430037f21fc289fd0f9b4e8c4aa7c3fa0cca4dd85b10fc6c
BLAKE2b-256 checksum
How to use checksums
9e25437c90664b7b738672200106b4330ac4f305d61f3a125509b6a3fac14b55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

Release files / rust_magic-0.3.3-py3-none-any.whl

Download URL rust_magic-0.3.3-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
94fab9c86fc3b0cbe95a9d01eab98c6659da37b48be9b97f66e572fdffc1a993
BLAKE2b-256 checksum
How to use checksums
b93e00dafca0df59098b44cdedc211f0e230f86ff7aa52c3a84ff44f6ce5cc28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page