This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn sum(x: i32, y: i32) -> i32 { | |
x + y | |
} | |
#[test] | |
fn it_works() { | |
assert!(sum(1, 2) == 3); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "scrape" | |
version = "0.1.0" | |
authors = ["Mike Piccolo <mfpiccolo@gmail.com>"] | |
[lib] | |
name = "embed" | |
crate-type = ["dylib"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[no_mangle] | |
pub extern fn sum(x: i32, y: i32) -> i32 { | |
x + y | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source ‘https://rubygems.org' | |
gem ‘ffi’ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require ‘ffi’ | |
module Scrape | |
extend FFI::Library | |
ffi_lib ‘./debug/libscrape.dylib’ | |
attach_function :sum, [:int32, :int32], :int32 | |
end | |
puts Scrape.sum(2, 3) == 5 ? “Gone Dun It!” : “Uhhhh????” |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[test] | |
fn it_works() { | |
assert!(true); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'this is a string'.class # => String | |
"this is a string".class # => String | |
%{this is a string}.class # => String | |
string = <<END | |
this is a string | |
END | |
string.class = # => String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"abcde".chars.reduce{|s,c| c + s } # => "edcba" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn reverse(s: String) -> String { | |
// reverse string here | |
} | |
#[test] | |
fn it_works() { | |
assert!( | |
reverse(“Don’t use palindrome”) == "emordnilap esu t'noD"; | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn reverse(s: String) -> String { | |
s.chars().rev() | |
} |