Esempio n. 1
0
            public REnumerator(RustFFIIterator d)
            {
                /// A default value
                var data = default(T);

                /// We pin the value
                handle = GCHandle.Alloc(data, GCHandleType.Pinned);
                /// We initialize the next() function
                next = Marshal.GetDelegateForFunctionPointer <RustIteratorNext>(d.Next);
                /// Store the iterator
                iterPtr = d.Iterator;
                /// We still haven't ended, since this is the constructor
                ended = false;
            }
        static void Main(string[] args)
        {
            /// Uninitialized iterator
            var iter = new RustFFIIterator();

            /// Initialize it in rust
            get_iterator(out iter);
            /// Create our special iterator for rust objects
            var i = new RustIter <Vec>(iter);

            /// Loop
            foreach (var b in i)
            {
                /// Loop on the list that rust sends us
                foreach (var c in b.ToList <ulong>())
                {
                    /// Print it
                    Console.Write(c + " ");
                }
                Console.WriteLine();
            }
            Console.ReadKey();
        }
 private static extern void get_iterator(out RustFFIIterator iter);
Esempio n. 4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="d">
 /// Iterator from rust
 /// </param>
 public RustIter(RustFFIIterator d)
 {
     ffiiter = d;
 }