Reidar Sollid's Blog

Just another site

Archive for the ‘Rust’ Category

Import Rust file to RustyCage

leave a comment »

The import Rust file wizard will copy a file from your file system into your current workspace in Eclipse. So from the “File” menu chose Import.

Screenshot from 2013-04-23 23:46:52

Then from the Import wizard you have the Rust category and in there you can chose Rust file. The Import Rust Project is not implemented as for now. Sorry.

Screenshot from 2013-04-23 23:48:13

Then press the “next>” button and chose the “src” folder.

Screenshot from 2013-04-23 23:48:38

Then press the “browse” button or enter the path to your file.Screenshot from 2013-04-23 23:49:30

Screenshot from 2013-04-23 23:49:51

Then press the “Finish” button.

Screenshot from 2013-04-23 23:50:16

And viola, your Rust file is imported/copied into your workspace and project.

Written by reidarsollid

April 23, 2013 at 10:00 pm

Posted in Rust, software

Introducing Rust Task

leave a comment »

So what is Rust then, from Wikipedia “Rust is an experimental, concurrent, multi-paradigm, compiled programming language developed by Mozilla Labs. It is designed to be practical, supporting pure-functional, concurrent-actor, imperative-procedural, and object-oriented styles.”
The most exiting thing for me is that it is influenced by Erlang and Limbo. Limbo with ports and channels and Erlang with the lightweight processes. I guess that Rust is designed with the purpose of writing web browser and to handle concurrency in a multi-core environment, these characteristics are well suited for backend systems as well.

In Rust we spawn out a new task, with the spawn keyword. This creates a lightweight process/task in which we can communicate with messages through channels. Default behavior for a variable in Rust is to be immutable, if you want a mutable variable you must explicitly declare it mutable with the mutable keyword.

So here is a little silly demo code of how to spawn a task and to send and receive messages from it.

use std;
import print = io:: println;

fn main() {
  let port = comm:: port::();
  let chan = comm:: chan::(port);
  do task:: spawn || {
    let result = compute_some();
    comm:: send(chan, result);
  let first_result = compute_another();
  let second_result = comm::recv(port);
  print(#fmt("First, %s", first_result));
  print(#fmt("Second, %s", second_result));

fn compute_some() -> str {
  ret "Some computation";

fn compute_another() -> str {
  ret "Another computation";

I create two functions compute_some() and compute_another() in which only returns a string to recognize which function has been executed. Then in the main function I create a port and creates a channel connected to the port.Then I spawn out a task to compute where I execute the compute_some() function and sends the result on the channel.Then I execute one function and assign the result to a variable and then fetches the result from the channel and assigns it to a second variable. Then prints the result. Not very needy of concurrency here, but I guess you get the point.

For more on Rust Rust-lang I recommend the tutorial. Rust tutorail

Written by reidarsollid

June 24, 2012 at 9:16 pm

Posted in Rust, software

RustyCage a Rust-lang IDE plugin for Eclipse

with 21 comments

I have created a Rust plugin for Eclipse, so here is a small intro how to use it.

First you need to chose the Rust perspective.


If you want code completion from the std libs, you need to download the rust source code and add rust home your rust preferences.


Then in the Rust perspective chose New RustProject


This opens the rust project wizard.


The default is lib, so if you want a executable you need to check of the lib check box. And fill inn version and author. Here is an example.


Press Finnish and your rust project is created. A crate file is created for your project.


No you probably want a rust file, chose new rust file.


This will open the new rust file wizard. Give the file a name. The must be a .rs or .rc file.


Then your crate file has been updated with your new rust file.


Now enter your code in the rust file. And you have the compile and the run buttons in your task bar. Compile and run uses the context of the file you are in, so you can either compile the crate or just one file.


Compile output in the console window.


And finally press the run button and you get the result in the console window.


You can fetch the plugin via github from

Or get it from update site

RustyCage is writen in Scala so you need the Scala compiler to install it.

Build your own update site with maven and tycho

Written by reidarsollid

March 27, 2012 at 5:17 pm

Posted in Rust, software