Skip to content

Instantly share code, notes, and snippets.

@mfpiccolo
Created July 21, 2015 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfpiccolo/d52f87db4590158ecd57 to your computer and use it in GitHub Desktop.
Save mfpiccolo/d52f87db4590158ecd57 to your computer and use it in GitHub Desktop.
require 'ffi'
module Scrape
extend FFI::Library
ffi_lib './target/debug/libscrape.dylib'
class FromRustArray < FFI::Struct
layout :len, :size_t, # dynamic array layout
:data, :pointer #
def to_a
self[:data].get_array_of_string(0, self[:len]).compact
end
end
attach_function :number_to_char_array, [], FromRustArray.by_value
end
p Scrape.number_to_char_array.to_a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment