text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: connectedcars/rumble path: /src/bluez/constants.rs #![allow(dead_code)] pub const HCI_COMMAND_PKT: u8 = 0x01; // hci.h pub const HCI_FILTER: i32 = 2; pub const HCI_EVENT_PKT: i32 = 0x04; pub const HCI_ACLDATA_PKT: i32 = 0x02; pub const HCI_LE_META_EVENT: i32 = 0x3E; pub const HCI_CHANNEL_RAW:...
code_fim
hard
{ "lang": "rust", "repo": "connectedcars/rumble", "path": "/src/bluez/constants.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: carrotflakes/slide path: /examples/main.rs use slide::densified_wta_hash::DensifiedWtaHash; use slide::network::{Case, LayerConfig, Network}; use slide::layer::NodeType; fn main() { let batch_size = 64; let learning_rate = 0.01; //0.0001; let input_size = 100; let case_per_rehas...
code_fim
hard
{ "lang": "rust", "repo": "carrotflakes/slide", "path": "/examples/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut cases = Vec::new(); for i in 0..1000 { let label = i % 10; let mut indices = vec![ rand::random::<usize>() % 5 * 10 + label, rand::random::<usize>() % 5 * 10 + label, rand::random::<usize>() % 5 * 10 + label, rand::random::<us...
code_fim
hard
{ "lang": "rust", "repo": "carrotflakes/slide", "path": "/examples/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..1000 { // dbg!("train..."); let rehash = i % (case_per_rehash / batch_size) == case_per_rehash / batch_size - 1; let rebuild = i % (case_per_rebuild / batch_size) == case_per_rebuild / batch_size - 1; network.train(&cases[i * batch_size % 900..], i, rehash, ...
code_fim
hard
{ "lang": "rust", "repo": "carrotflakes/slide", "path": "/examples/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tinh-phan/couchbase-rs path: /couchbase/examples/kv_basics.rs use couchbase::Cluster; use futures::executor::block_on; use serde_derive::Deserialize; #[derive(Debug, Deserialize)] struct Airport { airportname: String, icao: String, } <|fim_suffix|> println!( "First I...
code_fim
hard
{ "lang": "rust", "repo": "tinh-phan/couchbase-rs", "path": "/couchbase/examples/kv_basics.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let f = async { let found_doc = collection .get("airport_1297", None) .await .expect("Error while loading doc"); println!("Airline Document: {:?}", found_doc); println!("Content Decoded {:?}", found_doc.content_as::<Airport>()); prin...
code_fim
hard
{ "lang": "rust", "repo": "tinh-phan/couchbase-rs", "path": "/couchbase/examples/kv_basics.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!( "First Insert: {:?}", collection.insert("bla", "bla", None).await ); println!( "Second Insert: {:?}", collection.insert("bla", "bla", None).await ); cluster.disconnect().expect("Could not shutdown properly");...
code_fim
hard
{ "lang": "rust", "repo": "tinh-phan/couchbase-rs", "path": "/couchbase/examples/kv_basics.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kurenaif/javaparser.rs path: /src/semantics/import.rs use analyze::resolve::scope::{EnclosingTypeDef, Scope}; use parse::tree::{ImportDef, ImportPrefix, ImportPrefixDef}; use semantics::Context; use {analyze, parse}; pub fn apply<'def>(import: &mut parse::tree::Import<'def>, context: &mut Conte...
code_fim
hard
{ "lang": "rust", "repo": "kurenaif/javaparser.rs", "path": "/src/semantics/import.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> "# ]; assert_eq!( files.first().unwrap().unit.imports, vec![ Import { prefix_opt: Some(Box::new(ImportPrefix { prefix_opt: None, name: span2(3, 8, "dev2", files.get(0).unwra...
code_fim
hard
{ "lang": "rust", "repo": "kurenaif/javaparser.rs", "path": "/src/semantics/import.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> tokens_3: &str, tokens_4: &str, tokens_5: &str, ) -> Result<(), JsValue>; # [wasm_bindgen (catch , method , structural , js_class = "DOMTokenList" , js_name = remove)] #[doc = "The `remove()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mo...
code_fim
hard
{ "lang": "rust", "repo": "rustwasm/wasm-bindgen", "path": "/crates/web-sys/src/features/gen_DomTokenList.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rustwasm/wasm-bindgen path: /crates/web-sys/src/features/gen_DomTokenList.rs #![allow(unused_imports)] #![allow(clippy::all)] use super::*; use wasm_bindgen::prelude::*; #[wasm_bindgen] extern "C" { # [wasm_bindgen (extends = :: js_sys :: Object , js_name = DOMTokenList , typescript_type = "...
code_fim
hard
{ "lang": "rust", "repo": "rustwasm/wasm-bindgen", "path": "/crates/web-sys/src/features/gen_DomTokenList.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gabcoh/tauri path: /core/tauri-build/src/lib.rs // Copyright 2019-2021 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT #![cfg_attr(doc_cfg, feature(doc_cfg))] pub use anyhow::Result; use std::path::{Path, PathBuf}; #[cfg(f...
code_fim
hard
{ "lang": "rust", "repo": "gabcoh/tauri", "path": "/core/tauri-build/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Run all build time helpers for your Tauri Application. /// /// The current helpers include the following: /// * Generates a Windows Resource file when targeting Windows. /// /// # Platforms /// /// [`build()`] should be called inside of `build.rs` regardless of the platform: /// * New helpers may targ...
code_fim
hard
{ "lang": "rust", "repo": "gabcoh/tauri", "path": "/core/tauri-build/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl super::Cryptor for IdentityCryptor { fn finalize(self: Box<Self>) -> Result<Box<Target>, Error> { Ok(self.inner) } }<|fim_prefix|>// repo: abrodersen/backupmanager path: /src/encryption/identity.rs use std::io; use crate::destination::Target; use anyhow::Error; pub struct Identit...
code_fim
medium
{ "lang": "rust", "repo": "abrodersen/backupmanager", "path": "/src/encryption/identity.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.inner.write(buf) } fn flush(&mut self) -> io::Result<()> { self.inner.flush() } } impl super::Cryptor for IdentityCryptor { fn finalize(self: Box<Self>) -> Result<Box<Target>, Error> { Ok(self.inner) } }<|fim_prefix|>// repo: abrodersen/backupmanager pat...
code_fim
medium
{ "lang": "rust", "repo": "abrodersen/backupmanager", "path": "/src/encryption/identity.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abrodersen/backupmanager path: /src/encryption/identity.rs use std::io; use crate::destination::Target; use anyhow::Error; pub struct IdentityCryptor { inner: Box<Target>, } impl IdentityCryptor { pub fn new(w: Box<Target>) -> IdentityCryptor { IdentityCryptor { inner: w } ...
code_fim
medium
{ "lang": "rust", "repo": "abrodersen/backupmanager", "path": "/src/encryption/identity.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kingkongtree/new-tee-os path: /SGX/elfloader/src/lib.rs #![no_std] #![feature(alloc_error_hand<|fim_suffix|>lfloader; pub mod rsrvmalloc; pub use rsrvmalloc::MYALLOCATOR as MYALLOCATOR;<|fim_middle|>ler)] //#![feature(const_fn)] pub mod e
code_fim
easy
{ "lang": "rust", "repo": "kingkongtree/new-tee-os", "path": "/SGX/elfloader/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kingkongtree/new-tee-os path: /SGX/elfloader/src/lib.rs #![no_std] #![feature(alloc_error_handler)] //#![feature(const_fn)] pub mod e<|fim_suffix|>rsrvmalloc::MYALLOCATOR as MYALLOCATOR;<|fim_middle|>lfloader; pub mod rsrvmalloc; pub use
code_fim
easy
{ "lang": "rust", "repo": "kingkongtree/new-tee-os", "path": "/SGX/elfloader/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>lfloader; pub mod rsrvmalloc; pub use rsrvmalloc::MYALLOCATOR as MYALLOCATOR;<|fim_prefix|>// repo: kingkongtree/new-tee-os path: /SGX/elfloader/src/lib.rs #![no_std] #![feature(alloc_error_hand<|fim_middle|>ler)] //#![feature(const_fn)] pub mod e
code_fim
easy
{ "lang": "rust", "repo": "kingkongtree/new-tee-os", "path": "/SGX/elfloader/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flawedmatrix/detour-rs path: /src/error.rs //! Error types and utilities. use mmap_fixed as mmap; use region; error_chain! { foreign_links { RegionFailure(region::error::Error); AllocateFailure(mmap::MapError); } errors { /// A static detour has already been...
code_fim
hard
{ "lang": "rust", "repo": "flawedmatrix/detour-rs", "path": "/src/error.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>nnot allocate memory") } /// The address contains an external loop. UnsupportedLoop { display("address contains an unsupported loop") } /// The address contains an unsupported relative branch. UnsupportedRelativeBranch { display("address contains an unsupported branch") } ...
code_fim
hard
{ "lang": "rust", "repo": "flawedmatrix/detour-rs", "path": "/src/error.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let sdl_context = sdl2::init().unwrap(); let mut world = World { entities: Entities::new(), masses: Masses::new(), transforms: Transforms::new(), movements: Movements::new(), }; // Clear compiler unused warning world...
code_fim
hard
{ "lang": "rust", "repo": "Winwardo/snapback-game-engine", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Winwardo/snapback-game-engine path: /src/main.rs #[macro_use] extern crate log; extern crate env_logger; extern crate sdl2; extern crate time; extern crate rand; #[macro_use] extern crate bitflags; extern crate nalgebra; mod core; mod render; use core::*; use sdl2::Sdl; use sdl2::keyboard::Ke...
code_fim
hard
{ "lang": "rust", "repo": "Winwardo/snapback-game-engine", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bjoernQ/channel-f-bluepill path: /desktop/src/main.rs use std::{cell::RefCell, env, fs}; use minifb::{Key, Scale, ScaleMode, Window, WindowOptions}; use chf_emulator::Cpu; const WIDTH: usize = 128 * 2; const HEIGHT: usize = 64 * 2; const ROM_0000: &'static [u8] = include_bytes!("../../chf-em...
code_fim
hard
{ "lang": "rust", "repo": "bjoernQ/channel-f-bluepill", "path": "/desktop/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let color = COLORS[(pixel + palette * 4) as usize]; let addr = (y * 128 * 2 * 2) + (x * 2); buffer[addr + 0] = color; buffer[addr + 1] = color; buffer[addr + 256] = color; buffer[addr +...
code_fim
hard
{ "lang": "rust", "repo": "bjoernQ/channel-f-bluepill", "path": "/desktop/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: y15un/png-to-32bpp-rgba path: /src/main.rs use getopts::{Fail, Options}; use png::{Decoder, DecodingError}; use std::{ env, error::Error as StdError, fmt::{Display, Formatter, Result as FmtResult}, fs::{self, OpenOptions}, io::Error as IoError, }; fn print_usage(opts: Option...
code_fim
hard
{ "lang": "rust", "repo": "y15un/png-to-32bpp-rgba", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self::Png(src) } } impl StdError for Error { fn source(&self) -> Option<&(dyn StdError + 'static)> { match self { Self::Getopts(f) => Some(f), Self::Io(ioe) => Some(ioe), Self::Png(de) => Some(de), } } }<|fim_prefix|>// repo: y15un/pn...
code_fim
hard
{ "lang": "rust", "repo": "y15un/png-to-32bpp-rgba", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: decentninja/decent.ninja path: /src/main.rs #![feature(plugin)] #![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; extern crate rocket_contrib; use rocket_contrib::templates::Template; use rocket::response::NamedFile; use rocket::State; #[macro_use] extern crate serd...
code_fim
hard
{ "lang": "rust", "repo": "decentninja/decent.ninja", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[get("/<file..>")] fn files(file: PathBuf) -> Option<NamedFile> { NamedFile::open(Path::new("static/").join(file)).ok() } fn main() { let content = content::read_content("content.json").expect("Could not read content.json."); rocket::ignite() .mount("/", routes![index, files]) ...
code_fim
medium
{ "lang": "rust", "repo": "decentninja/decent.ninja", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let content = content::read_content("content.json").expect("Could not read content.json."); rocket::ignite() .mount("/", routes![index, files]) .manage(AppState { content: content }) .attach(Template::fairing()) .launch(); }<|fim_pref...
code_fim
hard
{ "lang": "rust", "repo": "decentninja/decent.ninja", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: smokku/naia-socket path: /client/src/impls/wasm_bindgen/client_socket.rs extern crate log; use log::info; use std::{collections::VecDeque, net::SocketAddr}; use crate::{ error::NaiaClientSocketError, link_conditioner::LinkConditioner, ClientSocketTrait, MessageSender, Packet, }; use n...
code_fim
hard
{ "lang": "rust", "repo": "smokku/naia-socket", "path": "/client/src/impls/wasm_bindgen/client_socket.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match self .message_queue .borrow_mut() .pop_front() .expect("message queue shouldn't be empty!") { Ok(Some(packet)) => { return Ok(Some(packet)); } O...
code_fim
hard
{ "lang": "rust", "repo": "smokku/naia-socket", "path": "/client/src/impls/wasm_bindgen/client_socket.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Box::new(ClientSocket { address: server_socket_address, message_queue, message_sender, dropped_outgoing_messages, }) } } #[allow(unsafe_code)] #[cfg(feature = "multithread")] unsafe impl Send for ClientSocket {} #[allow(unsafe_code)] #[c...
code_fim
hard
{ "lang": "rust", "repo": "smokku/naia-socket", "path": "/client/src/impls/wasm_bindgen/client_socket.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: clitetailor/cursortanium path: /src/parsers/json_parser/tokens.rs use serde::{Deserialize, Serialize}; #[derive(Serialize, D<|fim_suffix|>ng(String), Number(f64), Boolean(bool), Null, }<|fim_middle|>eserialize, Debug, PartialEq)] pub enum Value { Object(Vec<(String, Box<Value>)>...
code_fim
medium
{ "lang": "rust", "repo": "clitetailor/cursortanium", "path": "/src/parsers/json_parser/tokens.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ng(String), Number(f64), Boolean(bool), Null, }<|fim_prefix|>// repo: clitetailor/cursortanium path: /src/parsers/json_parser/tokens.rs use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, PartialEq)] pub enum Value { Object(<|fim_middle|>Vec<(String, Box<Value>)>...
code_fim
easy
{ "lang": "rust", "repo": "clitetailor/cursortanium", "path": "/src/parsers/json_parser/tokens.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>delegate_iter!([ B: CoArbitrary , F: Clone + FnMut(<I as Iterator>::Item) -> B , I: Clone + Iterator] Map<I, F>); delegate_iter!([ A: Clone + CoArbitrary] Once<A>); delegate_iter!([ T: Clone + CoArbitrary , A: Clone + Iterator<Item = T>] ...
code_fim
hard
{ "lang": "rust", "repo": "Centril/proptest-arbitrary", "path": "/src/coarbitrary/_std/iter.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Centril/proptest-arbitrary path: /src/coarbitrary/_std/iter.rs use coarbitrary::*; use std::iter::*; delegate_iter!([ T: CoArbitrary , A: Clone + Iterator<Item = T> , B: Clone + Iterator<Item = T>] Chain<A, B>); delegate_iter!(['a , ...
code_fim
hard
{ "lang": "rust", "repo": "Centril/proptest-arbitrary", "path": "/src/coarbitrary/_std/iter.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>delegate_iter!([ T: Clone + CoArbitrary , A: Clone + Iterator<Item = T>] Peekable<A>); delegate_iter!([ T: CoArbitrary , A: Clone + DoubleEndedIterator<Item = T>] Rev<A>); delegate_iter!([ B: CoArbitrary , I: Clone + Iterator ...
code_fim
hard
{ "lang": "rust", "repo": "Centril/proptest-arbitrary", "path": "/src/coarbitrary/_std/iter.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn next(&mut self) -> Option<Self::Item> { <EdgeCirculator<_, _>>::next(self).map(|edge| { OrphanEdgeView::new( unsafe { use std::mem; // There is no way to bind the anonymous lifetime of this // function ...
code_fim
hard
{ "lang": "rust", "repo": "timothyhollabaugh/plexus", "path": "/src/graph/topology/face.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> <FaceCirculator<_, _>>::next(self).map(|face| { OrphanFaceView::new( unsafe { use std::mem; // There is no way to bind the anonymous lifetime of this // function to `Self::Item`. This is problematic for the ...
code_fim
hard
{ "lang": "rust", "repo": "timothyhollabaugh/plexus", "path": "/src/graph/topology/face.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timothyhollabaugh/plexus path: /src/graph/topology/face.rs } } impl<M, G> FaceView<M, G> where M: AsRef<Mesh<G>>, G: FaceNormal + Geometry, { pub fn normal(&self) -> Result<G::Normal, Error> { G::normal(self.with_mesh_ref()) } } impl<'a, G> FaceView<&'a mut Mesh<G>, G...
code_fim
hard
{ "lang": "rust", "repo": "timothyhollabaugh/plexus", "path": "/src/graph/topology/face.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wuminzhe/evm-log-tracker path: /src/evm_client.rs use crate::Result; use web3::{ transports::http::Http, types::{BlockNumber, FilterBuilder, Log, SyncState, H160, H256, U64}, Web3, contract::{Contract, Options}, }; pub struct EvmClient { web3: Web3<Http>, } impl EvmClient {...
code_fim
medium
{ "lang": "rust", "repo": "wuminzhe/evm-log-tracker", "path": "/src/evm_client.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhangyuchi/rusttest path: /hello/src/fntest/fnoncetest.rs #[derive(Debug)] struct E { a: String, } impl Drop for E { fn drop(&mut self) { <|fim_suffix|>fn fn_once<F>(func: F) where F: FnOnce(), { println!("fn_once begins"); func(); //func(); println!("fn_once ended")...
code_fim
medium
{ "lang": "rust", "repo": "zhangyuchi/rusttest", "path": "/hello/src/fntest/fnoncetest.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn fn_once_test() { let e = E { a: "fn_once".to_string(), }; // 这样加个move,看看程序执行输出顺序有什么不同 // let f = move || println!("fn once calls: {:?}", e); let f = || println!("fnonce closure calls: {:?}", e); fn_once(f); println!("main ended"); }<|fim_prefix|>// repo: zhangyuc...
code_fim
medium
{ "lang": "rust", "repo": "zhangyuchi/rusttest", "path": "/hello/src/fntest/fnoncetest.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alondero/rust-invaders path: /src/views/main_menu.rs use engine::{Engine, View, ViewAction}; use engine::data::Rectangle; use engine::graphics::{Sprite, CopySprite}; use sdl2::pixels::Color; pub struct MainMenuView { actions: Vec<Action>, selected: i8, } impl MainMenuView { ...
code_fim
hard
{ "lang": "rust", "repo": "alondero/rust-invaders", "path": "/src/views/main_menu.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ViewAction::None } } struct Action { func: Box<Fn(&mut Engine) -> ViewAction>, idle_sprite: Sprite, hover_sprite: Sprite, } impl Action { fn new(engine: &mut Engine, label: &'static str, func: Box<Fn(&mut Engine) -> ViewAction>) -> Action { Action { ...
code_fim
hard
{ "lang": "rust", "repo": "alondero/rust-invaders", "path": "/src/views/main_menu.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use std::collections::hash_map::DefaultHasher; let mut s = DefaultHasher::new(); t.hash(&mut s); s.finish() } #[cfg(test)] mod test { use super::*; use std::collections::HashSet; #[test] fn hash_str() { assert_eq!(HashValue::<str>::from("hash_str"), "hash_str"); ...
code_fim
hard
{ "lang": "rust", "repo": "kevinw/crayon", "path": "/src/utils/hash_value.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kevinw/crayon path: /src/utils/hash_value.rs use std::hash::{Hash, Hasher}; use std::marker::PhantomData; use std::path::Path; #[derive(Serialize, Deserialize, Debug, Eq)] pub struct HashValue<T>(u64, PhantomData<T>) where T: Hash + ?Sized; impl<T> HashValue<T> where T: Hash + ?Sized, ...
code_fim
hard
{ "lang": "rust", "repo": "kevinw/crayon", "path": "/src/utils/hash_value.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andrehjr/ray_tracing_challenge path: /tests/matrix.rs use raytracer::*; #[test] fn test_basic_matrix() { let matrix = matrix![3.0, 1.0 ; 2.0, 7.0]; assert_eq!(matrix.at(0, 1), 1.0); assert_eq!(matrix.at(1, 1), 7.0); assert_eq!(matrix.at(0, 0), 3.0); assert_eq!(matrix.at(1, ...
code_fim
hard
{ "lang": "rust", "repo": "andrehjr/ray_tracing_challenge", "path": "/tests/matrix.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( matrix![-0.15385, -0.15385, -0.28205, -0.53846; -0.07692, 0.12308, 0.02564, 0.03077; 0.35897, 0.35897, 0.43590, 0.92308; -0.69231, -0.69231, -0.76923, -1.92308], matrix_a.inverse() ); let matrix_b = matrix![9.0, 3.0, 0.0, 9.0; ...
code_fim
hard
{ "lang": "rust", "repo": "andrehjr/ray_tracing_challenge", "path": "/tests/matrix.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>::c_int, sampling_rate: ::std::os::raw::c_int, callib_coef1: f64, callib_coef2: f64, callib_coef3: f64, oxygen_level: *mut f64, ) -> ::std::os::raw::c_int; } extern "C" { pub fn restore_data_from_wavelet_detailed_coeffs( data: *mut f64, data_...
code_fim
hard
{ "lang": "rust", "repo": "neuroidss/brainflow", "path": "/rust_package/brainflow/src/ffi/data_handler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: neuroidss/brainflow path: /rust_package/brainflow/src/ffi/data_handler.rs /* automatically generated by rust-bindgen 0.59.2 */ #![allow(non_camel_case_types)] extern "C" { pub fn perform_lowpass( data: *mut f64, data_len: ::std::os::raw::c_int, sampling_rate: ::std...
code_fim
hard
{ "lang": "rust", "repo": "neuroidss/brainflow", "path": "/rust_package/brainflow/src/ffi/data_handler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> todelete.push(id.to_string()); // } writeln!( &mut file, "{} {} = {} ({})", id, tag_name, item_name, mod_name ) .unwrap(); } } /* let token = mw.get_token().unwrap(); for chunk in tod...
code_fim
hard
{ "lang": "rust", "repo": "FTB-Gamepedia/mediawiki-rs", "path": "/src/bin/verifyoretile.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FTB-Gamepedia/mediawiki-rs path: /src/bin/verifyoretile.rs use mediawiki::{oredict::Oredict, tilesheet::Tilesheet, Mediawiki}; use std::{ collections::HashSet, fs::File, io::{BufWriter, Write}, }; fn import() { let path = "Invalid Ores.txt"; let mw = Mediawiki::login_path("f...
code_fim
hard
{ "lang": "rust", "repo": "FTB-Gamepedia/mediawiki-rs", "path": "/src/bin/verifyoretile.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Get the `release` value. pub fn release(&self) -> &str { if let Some(ref release) = self.release { release } else { "" } } /// Set the `release` value. pub fn set_release(&mut self, release: Option<String>) -> &mut Info { sel...
code_fim
hard
{ "lang": "rust", "repo": "waffle-iron/mimir-1", "path": "/src/common/version.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Display for Info { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { writeln!(f, "{}", self.version)?; if let Some(ref release) = self.release { writeln!(f, "{}", release)?; } Ok(()) } }<|fim_prefix|>// repo: waffle-iron/mimir-1 path: /...
code_fim
hard
{ "lang": "rust", "repo": "waffle-iron/mimir-1", "path": "/src/common/version.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: waffle-iron/mimir-1 path: /src/common/version.rs // Copyright (c) 2017 oic developers // // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT // license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // optio...
code_fim
hard
{ "lang": "rust", "repo": "waffle-iron/mimir-1", "path": "/src/common/version.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl HasSpan for BindSimple { fn span(&self) -> Span { self.span } } impl PartialEq for BindSimple { fn eq(&self, other: &Self) -> bool { self.name == other.name && self.expr == other.expr && self.comment == other.comment } } #[derive(Clone, Debug)] pub struct BindInherit...
code_fim
hard
{ "lang": "rust", "repo": "seese/nix-language-server", "path": "/nix-parser/src/ast.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone, Debug)] pub struct ExprIf { cond: Box<Expr>, body: Box<Expr>, fallback: Box<Expr>, span: Span, } impl ExprIf { pub fn new(cond: Box<Expr>, body: Box<Expr>, fallback: Box<Expr>, span: Span) -> Self { ExprIf { cond, body, fallb...
code_fim
hard
{ "lang": "rust", "repo": "seese/nix-language-server", "path": "/nix-parser/src/ast.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seese/nix-language-server path: /nix-parser/src/ast.rs &mut Formatter) -> FmtResult { match *self { UnaryOp::Neg => fmt.write_str("-"), UnaryOp::Not => fmt.write_str("!"), } } } #[derive(Clone, Debug)] pub struct ExprUnary { op: UnaryOp, expr...
code_fim
hard
{ "lang": "rust", "repo": "seese/nix-language-server", "path": "/nix-parser/src/ast.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/storage/fxfs/src/drop_event.rs // Copyright 2022 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use {event_listener::Event, std::ops::Deref}; /// Same as Event but not...
code_fim
medium
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/storage/fxfs/src/drop_event.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } impl DropEvent { pub fn new() -> Self { Self(Event::new()) } }<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/storage/fxfs/src/drop_event.rs // Copyright 2022 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style licens...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/storage/fxfs/src/drop_event.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl TryFrom<&[char]> for Codon { type Error = (); fn try_from(value: &[char]) -> Result<Self, Self::Error> { match value { [a, b, c] => Ok(Codon(DNA::from(a), DNA::from(b), DNA::from(c))), _ => Err(()), } } } #[cfg(test)] mod tests { use super::*;...
code_fim
hard
{ "lang": "rust", "repo": "robsyme/rustalind", "path": "/src/seq/codon.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn try_from(value: &[char]) -> Result<Self, Self::Error> { match value { [a, b, c] => Ok(Codon(DNA::from(a), DNA::from(b), DNA::from(c))), _ => Err(()), } } } #[cfg(test)] mod tests { use super::*; use super::DNA::{T,A,C,G}; use ::seq::translati...
code_fim
hard
{ "lang": "rust", "repo": "robsyme/rustalind", "path": "/src/seq/codon.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: robsyme/rustalind path: /src/seq/codon.rs //use seq::translation::{TranslationTable, TranslatedCodon}; use super::nuc::DNA; use seq::translation::{TranslationTable, TranslatedCodon}; use std::convert::TryFrom; #[derive(Debug, PartialEq)] pub struct Codon(DNA, DNA, DNA); impl Codon { pub fn...
code_fim
hard
{ "lang": "rust", "repo": "robsyme/rustalind", "path": "/src/seq/codon.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ptrskay3/gaussian-beams path: /src/lib.rs #![warn(clippy::all)] #![feature(test)] pub mod beam; pub mod color; pub mod fft; pub mod scene; use crate::fft::fft; use ndarray::Array; use ndarray::{ArrayD, ArrayViewD, ArrayViewMutD}; use numpy::{IntoPyArray, PyArray1}; use numpy::{PyArrayDyn, PyRe...
code_fim
hard
{ "lang": "rust", "repo": "Ptrskay3/gaussian-beams", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn axpy(a: f64, x: ArrayViewD<'_, f64>, y: ArrayViewD<'_, f64>) -> ArrayD<f64> { a * &x + &y } fn mult(a: f64, mut x: ArrayViewMutD<'_, f64>) { x *= a; } #[pyfn(m, name = "axpy")] fn axpy_py<'py>( py: Python<'py>, a: f64, x: PyReadonlyArray...
code_fim
hard
{ "lang": "rust", "repo": "Ptrskay3/gaussian-beams", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/rust-docstrings path: /src/types.rs /// A Rust identifier pub type Identifier = String; /// A Rust pattern, as used in pattern matching. pub type Pattern = String; /// Documentation, a Markdown `String` pub type Documentation = String; <|fim_suffix|>/// Documentation sections #[derive...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/rust-docstrings", "path": "/src/types.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Information extracted from a doc comment #[derive(Debug, PartialEq, Eq, Clone, Hash)] pub struct DocBlock { /// First line pub teaser: String, /// Paragraphs after first line pub description: Option<Documentation>, /// Sections pub sections: Vec<DocSection>, } /// Documentatio...
code_fim
medium
{ "lang": "rust", "repo": "iCodeIN/rust-docstrings", "path": "/src/types.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ukarlsson/um path: /src/um.rs #![feature(box_syntax)] #![allow(unstable)] extern crate arena; use std::os; use std::io::File; use std::io::IoErrorKind::EndOfFile; fn main() { let args: Vec<String> = os::args(); let mut registers = [0u32; 8]; let mut arrays: Vec<Vec<u32>> = vec!(); ...
code_fim
hard
{ "lang": "rust", "repo": "ukarlsson/um", "path": "/src/um.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match op { 0u32 => if registers[c] != 0 { registers[a] = registers[b] }, 1u32 => registers[a] = arrays[registers[b] as usize][registers[c] as usize], 2u32 => arrays[registers[a] as usize][registers[b] as usize] = registers[c], 3u32 => registers[a] = registers[b] + registers[...
code_fim
hard
{ "lang": "rust", "repo": "ukarlsson/um", "path": "/src/um.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> 9u32 => { let n = registers[c] as usize; arrays[n] = vec!(); abandoned.push(n); }, 10u32 => match std::io::stdout().write_u8(registers[c] as u8) { Err(why) => panic!("! {:?}", why.kind), Ok(_) => () }, 11u32 => ...
code_fim
hard
{ "lang": "rust", "repo": "ukarlsson/um", "path": "/src/um.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>extern crate libc; mod beta; mod error; mod gamma; mod math; mod consts; pub use beta::Beta; pub use error::Error; pub use gamma::Gamma;<|fim_prefix|>// repo: zolkko/special path: /src/lib.rs //! [Special functions][1]. //! //! [1]: https://en.wikipedia.org/wiki/Special_functions <|fim_middle|>#[cfg(t...
code_fim
easy
{ "lang": "rust", "repo": "zolkko/special", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zolkko/special path: /src/lib.rs //! [Special functions][1]. //! //! [1]: https://en.wikipedia.org/wiki/Special_functions #[cfg(test)] extern crate assert; <|fim_suffix|>pub use beta::Beta; pub use error::Error; pub use gamma::Gamma;<|fim_middle|>extern crate libc; mod beta; mod error; mod ga...
code_fim
medium
{ "lang": "rust", "repo": "zolkko/special", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>iveSD ( pAbsoluteSD : PSECURITY_DESCRIPTOR pSelfRelativeSD : PSECURITY_DESCRIPTOR lpdwBufferLength : LPDWORD ) - > BOOL ; pub fn MapGenericMask ( AccessMask : PDWORD GenericMapping : PGENERIC_MAPPING ) ; pub fn ObjectCloseAuditAlarmW ( SubsystemName : LPCWSTR HandleId : LPVOID GenerateOnClose : BOOL ) - >...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/winapi/src/um/securitybaseapi.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/winapi/src/um/securitybaseapi.rs notice may not be copied modified or distributed / / except according to those terms . / / ! FFI bindings to psapi . use shared : : guiddef : : GUID ; use shared : : minwindef : : { BOOL BYTE DWORD LPBOOL LPDWOR...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/winapi/src/um/securitybaseapi.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/winapi/src/um/securitybaseapi.rs h notice may not be copied modified or distributed / / except according to those terms . / / ! FFI bindings to psapi . use shared : : guiddef : : GUID ; use shared : : minwindef : : { BOOL BYTE DWORD LPBOOL LPDW...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/winapi/src/um/securitybaseapi.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>let rslt = c.members_and_watch(&alice_pair).await.unwrap(); assert!(rslt.events.iter().any(|e| e.variant == "Members")); }<|fim_prefix|>// repo: mellab/vln-node path: /vln-rpc/tests/integration_tests/members.rs use crate::initial; use vln_rpc::MembersCallExt; pub async fn<|fim_middle|> members() { ...
code_fim
medium
{ "lang": "rust", "repo": "mellab/vln-node", "path": "/vln-rpc/tests/integration_tests/members.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mellab/vln-node path: /vln-rpc/tests/integration_tests/members.rs use crate::initial; use vln_rpc::MembersCallExt; pub async fn<|fim_suffix|> assert!(rslt.events.iter().any(|e| e.variant == "Members")); }<|fim_middle|> members() { let (alice_pair, _, c) = initial().await; let rslt = c.m...
code_fim
medium
{ "lang": "rust", "repo": "mellab/vln-node", "path": "/vln-rpc/tests/integration_tests/members.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: quietboil/sibyl path: /src/types/number.rs /** Adds a Number to this Number and returns the sum as a new Number # Example ``` use sibyl::{ self as oracle, Number }; let env = oracle::env()?; let num = Number::from_int(19, &env)?; let a...
code_fim
hard
{ "lang": "rust", "repo": "quietboil/sibyl", "path": "/src/types/number.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Example ``` use sibyl::{ self as oracle, Number }; let env = oracle::env()?; let num = Number::from_int(-42, &env)?; let res = num.abs()?; assert_eq!(res.to_int::<i32>()?, 42); # Ok::<(),oracle::Error>(()) ``` */ pub fn ab...
code_fim
hard
{ "lang": "rust", "repo": "quietboil/sibyl", "path": "/src/types/number.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: quietboil/sibyl path: /src/types/number.rs tes an uninitialized OCI number. This simplified version of `u128_into_number` is used to create an output variable buffer. **Note** that we cannot pass an `uninit` version of `OCINumber` to be used for output. While `uninit` variant works ...
code_fim
hard
{ "lang": "rust", "repo": "quietboil/sibyl", "path": "/src/types/number.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/miri path: /tests/fail/modifying_constants.rs // This should fail even without validation/SB //@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows <|fim_suffix|> let x = &1; // the `&1` is promoted to a constant, but it used to be that only the pointer is marke...
code_fim
easy
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/tests/fail/modifying_constants.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let x = &1; // the `&1` is promoted to a constant, but it used to be that only the pointer is marked static, not the pointee let y = unsafe { &mut *(x as *const i32 as *mut i32) }; *y = 42; //~ ERROR: read-only assert_eq!(*x, 42); }<|fim_prefix|>// repo: rust-lang/miri path: /tests/fail/m...
code_fim
easy
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/tests/fail/modifying_constants.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yatesco/war-of-empires path: /app/wasm/src/lib.rs extern crate core; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use web_sys::{console, window, HtmlCanvasElement, KeyboardEvent}; use crate::core::game::Game; use crate::core::reducers::settings::Settings; use crate::core::reducers::...
code_fim
hard
{ "lang": "rust", "repo": "yatesco/war-of-empires", "path": "/app/wasm/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> context.set_fill_style(&"black".into()); context.set_stroke_style(&"blue".into()); context.set_text_align(&"center"); context.set_font(&"12px Arial"); context ...
code_fim
hard
{ "lang": "rust", "repo": "yatesco/war-of-empires", "path": "/app/wasm/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for tiles in s.next.game.views.values() { for tile in tiles { match tile { Some(t) => { context.begin_path(); context.set_fill_style(&"transparent".into()); context.fill_rect( ...
code_fim
hard
{ "lang": "rust", "repo": "yatesco/war-of-empires", "path": "/app/wasm/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gordonhart/bfi path: /src/interpreter.rs //! The interpreter resposible for executing programs. use std::cell::RefMut; use std::default::Default; use std::fmt::{self, Debug}; use std::io::{Read, Write}; use crate::ioctx::IoCtx; use crate::repl; use crate::token::Token; /// Current status of ...
code_fim
hard
{ "lang": "rust", "repo": "gordonhart/bfi", "path": "/src/interpreter.rs", "mode": "psm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_suffix|> fn value_decrement(&mut self) { self.data[self.data_ptr] = self.data[self.data_ptr].wrapping_sub(1); } fn put_character(&mut self) { if let Some(ctx_inner) = self.ctx.iter_mut().next() { (*ctx_inner).write_all(&self.data[self.data_ptr..=self.data_ptr]).unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "gordonhart/bfi", "path": "/src/interpreter.rs", "mode": "spm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_suffix|> pub fn resize(&mut self, width: u32, height: u32) { self.sc_desc.width = width; self.sc_desc.height = height; self.swap_chain = self.device.create_swap_chain(&self.surface, &self.sc_desc); let aspect_ratio = width as f32 / height as f32; let projection = cgmath...
code_fim
hard
{ "lang": "rust", "repo": "sierra-zero/dotrix", "path": "/src/renderer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sierra-zero/dotrix path: /src/renderer.rs mod light; mod r#static; pub use r#static::*; pub use light::{Light, LightUniform}; use winit::window::Window; pub struct Renderer { device: wgpu::Device, queue: wgpu::Queue, swap_chain: wgpu::SwapChain, sc_desc: wgpu::SwapChainDescrip...
code_fim
hard
{ "lang": "rust", "repo": "sierra-zero/dotrix", "path": "/src/renderer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mulimoen/hdf5-rust path: /hdf5/src/util.rs use std::borrow::Borrow; use std::convert::TryInto; use std::ffi::{CStr, CString}; use std::ptr; use std::str; use crate::internal_prelude::*; /// Convert a zero-terminated string (`const char *`) into a `String`. pub fn string_from_cstr(string: *cons...
code_fim
hard
{ "lang": "rust", "repo": "mulimoen/hdf5-rust", "path": "/hdf5/src/util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use crate::globals::H5E_CANTOPENOBJ; use super::{get_h5_str, string_from_cstr, to_cstring}; #[test] pub fn test_string_cstr() { let s1 = "foo".to_owned(); let c_s1 = to_cstring(s1.clone()).unwrap(); assert_eq!(s1, string_from_cstr(c_s1.as_ptr())); let s2 =...
code_fim
hard
{ "lang": "rust", "repo": "mulimoen/hdf5-rust", "path": "/hdf5/src/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qmutz/wallet713 path: /src/main.rs #[macro_use] extern crate serde_derive; #[macro_use] extern crate prettytable; #[macro_use] extern crate log; #[macro_use] extern crate serde_json; #[macro_use] extern crate gotham_derive; #[macro_use] extern crate clap; extern crate env_logger; extern crate bl...
code_fim
hard
{ "lang": "rust", "repo": "qmutz/wallet713", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let config = do_config(args, &chain, true, None, args.value_of("config-path"))?; set_mining_mode(config.chain.clone().unwrap_or(ChainTypes::Mainnet)); Ok(config) } fn main() { enable_ansi_support(); let matches = App::new("wallet713") .version(crate_version!()) .arg(...
code_fim
hard
{ "lang": "rust", "repo": "qmutz/wallet713", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tidwall/RetroSwiper path: /dev/retroswiper/src/main.rs use std::collections::HashMap; use std::fs; use std::fs::File; use std::io::prelude::*; use std::io::{BufRead, BufReader}; use std::path::Path; use std::process::{Child, Command, Stdio}; use std::time::{SystemTime, UNIX_EPOCH}; fn load_path...
code_fim
hard
{ "lang": "rust", "repo": "tidwall/RetroSwiper", "path": "/dev/retroswiper/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut codes = Vec::new(); for line in stdout_lines { if let Ok(line) = line { if line.contains("(EV_KEY)") && line.contains("(KEY_") && line.contains(", value 0") { let code = line.split("(KEY_").collect::<Vec<&str>>()[1] ...
code_fim
hard
{ "lang": "rust", "repo": "tidwall/RetroSwiper", "path": "/dev/retroswiper/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self { network_id: transaction.network_id as u32, contract: transaction.contract.clone(), sender: transaction.sender.clone()[..].try_into().unwrap(), nonce: transaction.nonce as u32, function: transaction.function.clone(), arg...
code_fim
hard
{ "lang": "rust", "repo": "ellipticoin/ellipticoind", "path": "/ellipticoind/src/models/transaction.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ellipticoin/ellipticoind path: /ellipticoind/src/models/transaction.rs use crate::{ config::get_pg_connection, diesel::{ExpressionMethods, RunQueryDsl}, models::block::Block, schema::{ transactions, transactions::{ columns::{nonce, sender}, ...
code_fim
hard
{ "lang": "rust", "repo": "ellipticoin/ellipticoind", "path": "/ellipticoind/src/models/transaction.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dmerejkowsky/dmenv path: /src/cli/commands/mod.rs mod develop; mod init; mod install; mod lock; mod pip; mod run; mod scripts; mod show; mod tidy; mod venv; pub use develop::develop; pub us<|fim_suffix|>, install_editable_with_constraint, upgrade_pip}; pub use run::{run, run_and_die}; pub use s...
code_fim
medium
{ "lang": "rust", "repo": "dmerejkowsky/dmenv", "path": "/src/cli/commands/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }