text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> /// Look up the SOA records associated with `name`. /// /// On completion, `handler` is called with the result. pub fn query_soa<F>(&mut self, name: &str, handler: F) where F: FnOnce(Result<SOAResult, AresError>) + 'static { let c_name = CString::new(name).unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "CJTozer/rust-c-ares", "path": "/src/channel.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Likewise for lookups. for c_lookup in options.lookups.iter() { options.ares_options.lookups = c_lookup.as_ptr() as *mut libc::c_char; } // Initialize the channel. let mut ares_channel = ptr::null_mut(); let channel_rc = unsafe...
code_fim
hard
{ "lang": "rust", "repo": "CJTozer/rust-c-ares", "path": "/src/channel.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CJTozer/rust-c-ares path: /src/channel.rs ons.tcp_port = tcp_port as libc::c_ushort; self.optmask = self.optmask | c_ares_sys::ARES_OPT_TCP_PORT; self } /// Set the domains to search, instead of the domains specified in /// resolv.conf or the domain derived from the ...
code_fim
hard
{ "lang": "rust", "repo": "CJTozer/rust-c-ares", "path": "/src/channel.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Eq for Uuid {} impl Ord for Uuid { fn cmp(&self, other: &Uuid) -> Ordering { self.0 .time_and_version .cmp(&other.0.time_and_version) .then(self.0.clock_seq_and_node.cmp(&other.0.clock_seq_and_node)) } } impl PartialOrd for Uuid { fn partial_c...
code_fim
hard
{ "lang": "rust", "repo": "Metaswitch/cassandra-rs", "path": "/src/cassandra/uuid.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Metaswitch/cassandra-rs path: /src/cassandra/uuid.rs use crate::cassandra::error::*; use crate::cassandra::util::{Protected, ProtectedInner}; use crate::cassandra_sys::cass_uuid_from_string_n; use crate::cassandra_sys::cass_uuid_gen_free; use crate::cassandra_sys::cass_uuid_gen_from_time; use c...
code_fim
hard
{ "lang": "rust", "repo": "Metaswitch/cassandra-rs", "path": "/src/cassandra/uuid.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn main() -> aoc::Result<()> { env_logger::init(); if let Err(e) = solve() { let stderr = io::stderr(); let mut w = stderr.lock(); writeln!(w, "Error: {}", e)?; while let Some(e) = e.source() { writeln!(w, "\t{}", e)?; } std::process::ex...
code_fim
medium
{ "lang": "rust", "repo": "foo-jin/advent-of-code", "path": "/template/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: foo-jin/advent-of-code path: /template/src/main.rs use std::{ io::{self, Read, Write}, }; fn parse(s: String) -> aoc::Result<Input> { s } fn level1(input: ..) -> aoc::Result<()> { Ok(()) } fn solve() -> aoc::Result<()> { let mut input = String::new(); io::stdin().read_to_s...
code_fim
medium
{ "lang": "rust", "repo": "foo-jin/advent-of-code", "path": "/template/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl convert::From<bincode::Error> for Error { fn from(error: bincode::Error) -> Self { Error::BincodeError(error) } } pub type Result<T> = std::result::Result<T, Error>;<|fim_prefix|>// repo: Dushistov/ublox path: /src/error.rs use std::convert; use std::io; #[derive(Debug)] pub enum E...
code_fim
medium
{ "lang": "rust", "repo": "Dushistov/ublox", "path": "/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Dushistov/ublox path: /src/error.rs use std::convert; use std::io; #[derive(Debug)] pub enum Error { InvalidChecksum, UnexpectedPacket, TimedOutWaitingForAck(u8, u8), IoError(io::Error), BincodeError(bincode::Error), } impl convert::From<io::Error> for Error { fn from(e...
code_fim
medium
{ "lang": "rust", "repo": "Dushistov/ublox", "path": "/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Error::BincodeError(error) } } pub type Result<T> = std::result::Result<T, Error>;<|fim_prefix|>// repo: Dushistov/ublox path: /src/error.rs use std::convert; use std::io; #[derive(Debug)] pub enum Error { InvalidChecksum, UnexpectedPacket, TimedOutWaitingForAck(u8, u8), IoE...
code_fim
medium
{ "lang": "rust", "repo": "Dushistov/ublox", "path": "/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jamestiotio/overdue_backend path: /src/db.rs use actix_web::web; use deadpool_postgres::Client; use native_tls::{Certificate, TlsConnector}; use postgres_native_tls::MakeTlsConnector; use tokio_pg_mapper::FromTokioPostgresRow; use tokio_postgres::types::{Json, Type}; use crate::{ constants,...
code_fim
hard
{ "lang": "rust", "repo": "jamestiotio/overdue_backend", "path": "/src/db.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(return_value) } pub async fn get_score_entries( client: &Client, limit: i64, difficulty: i32, ) -> Result<Vec<LeaderboardMultipleEntries>, CustomError> { // If multiple score entries have the same rank due to same score, order them by // the time they are added to the database ...
code_fim
hard
{ "lang": "rust", "repo": "jamestiotio/overdue_backend", "path": "/src/db.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alan-turing-institute/uatk-spc path: /src/init/lockdown.rs use std::collections::BTreeMap; use anyhow::Result; use fs_err::File; use serde::Deserialize; use crate::pb::Lockdown; use crate::{County, MSOA}; #[instrument(skip_all)] pub fn calculate_lockdown_per_day( msoas_per_county: BTreeMa...
code_fim
hard
{ "lang": "rust", "repo": "alan-turing-institute/uatk-spc", "path": "/src/init/lockdown.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Indexed by day. This is change, with all all matching counties listed let mut all_changes_per_day: Vec<Vec<f32>> = Vec::new(); for rec in csv::Reader::from_reader(File::open( "data/raw_data/nationaldata-v2/timeAtHomeIncreaseCTY.csv", )?) .deserialize() { let rec...
code_fim
hard
{ "lang": "rust", "repo": "alan-turing-institute/uatk-spc", "path": "/src/init/lockdown.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Now average per day let mut change_per_day = Vec::new(); for changes in all_changes_per_day { let n = changes.len() as f32; let avg = changes.into_iter().sum::<f32>() / n; change_per_day.push(avg); } Ok(Lockdown { start_date: day0.to_string(), ...
code_fim
hard
{ "lang": "rust", "repo": "alan-turing-institute/uatk-spc", "path": "/src/init/lockdown.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut output_buffer = self.output_buffer.lock().unwrap(); let mut output_frames = self.output_frames.lock().unwrap(); let new_frame = output_buffer.drain(..).collect(); output_frames.push(new_frame); let mut last_snapshot_time = self.last_snapshot_time.lock().unwr...
code_fim
hard
{ "lang": "rust", "repo": "TheLostLambda/zellij", "path": "/src/tests/fakes.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TheLostLambda/zellij path: /src/tests/fakes.rs use std::collections::{HashMap, VecDeque}; use std::io::Write; use std::os::unix::io::RawFd; use std::path::PathBuf; use std::sync::{Arc, Condvar, Mutex}; use std::time::{Duration, Instant}; use zellij_utils::{nix, zellij_tile}; use crate::tests::...
code_fim
hard
{ "lang": "rust", "repo": "TheLostLambda/zellij", "path": "/src/tests/fakes.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pola-rs/polars path: /crates/polars-plan/src/dsl/arity.rs use super::*; /// Utility struct for the `when-then-otherwise` expression. /// /// Represents the state of the expression after [when] is called. /// /// In this state, `then` must be called to continue to finish the expression. #[derive...
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/crates/polars-plan/src/dsl/arity.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl ChainedThen { /// Add another condition to the `when-then-otherwise` expression. pub fn when<E: Into<Expr>>(mut self, condition: E) -> ChainedWhen { self.conditions.push(condition.into()); ChainedWhen { conditions: self.conditions, statements: self.sta...
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/crates/polars-plan/src/dsl/arity.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pimox/proxmox-backup path: /src/api2/node.rs //! Server/Node Configuration and Administration use std::net::TcpListener; use std::os::unix::io::AsRawFd; use anyhow::{bail, format_err, Error}; use futures::future::{FutureExt, TryFutureExt}; use hyper::body::Body; use hyper::http::request::Parts...
code_fim
hard
{ "lang": "rust", "repo": "pimox/proxmox-backup", "path": "/src/api2/node.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ticket = Ticket::new(ticket::TERM_PREFIX, &Empty)? .sign( crate::auth_helpers::private_auth_key(), Some(&ticket::term_aad(&userid, &path, port)), )?; let mut command = Vec::new(); match cmd.as_deref() { Some("login") | None => { ...
code_fim
hard
{ "lang": "rust", "repo": "pimox/proxmox-backup", "path": "/src/api2/node.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>l: ", p].concat().as_bytes()) .expect("Couldn't write to output!"); } else { io::stdout() .write_all(b"Error: Download OK, issue with its file name!") .expect...
code_fim
hard
{ "lang": "rust", "repo": "spamwax/alfred-pinboard-rs", "path": "/src/commands/upgrade.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spamwax/alfred-pinboard-rs path: /src/commands/upgrade.rs use super::{io, process, Runner, SubCommand}; use std::io::Write; impl<'api, 'pin> Runner<'api, 'pin> { pub fn upgrade(&self, cmd: &SubCommand) { debug!("Starting in upgrade"); match *cmd { SubCommand::Sel...
code_fim
hard
{ "lang": "rust", "repo": "spamwax/alfred-pinboard-rs", "path": "/src/commands/upgrade.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Frezc/leetcode-solutions path: /src/n0129_sum_root_to_leaf_numbers.rs /** * [129] Sum Root to Leaf Numbers * * Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. * * An example is the root-to-leaf path 1->2->3 which represents the number 1...
code_fim
hard
{ "lang": "rust", "repo": "Frezc/leetcode-solutions", "path": "/src/n0129_sum_root_to_leaf_numbers.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geometryolife/goscript path: /vm/src/value.rs ValueType::Int16 => union_op_wrap!($a, $b, int16, $op), ValueType::Int32 => union_op_wrap!($a, $b, int32, $op), ValueType::Int64 => union_op_wrap!($a, $b, int64, $op), ValueType::Uint => union_op_wrap!($a,...
code_fim
hard
{ "lang": "rust", "repo": "geometryolife/goscript", "path": "/vm/src/value.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> match (self, b) { (Self::Bool(x), Self::Bool(y)) => x.cmp(y), (Self::Int(x), Self::Int(y)) => x.cmp(y), (Self::Int8(x), Self::Int8(y)) => x.cmp(y), (Self::Int16(x), Self::Int16(y)) => x.cmp(y), (Self::Int32(x), Self::Int32(y)) => x.cmp(y)...
code_fim
hard
{ "lang": "rust", "repo": "geometryolife/goscript", "path": "/vm/src/value.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl Eq for GosValue {} impl PartialEq for GosValue { #[inline] fn eq(&self, b: &GosValue) -> bool { match (self, b) { (Self::Nil(_), Self::Nil(_)) => true, (Self::Bool(x), Self::Bool(y)) => x == y, (Self::Int(x), Self::Int(y)) => x == y, (S...
code_fim
hard
{ "lang": "rust", "repo": "geometryolife/goscript", "path": "/vm/src/value.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Toure/tornado path: /tornado/common/tests/nats_test.rs #![cfg(feature = "nats_integration_tests")] // // This tests require docker on the host machine // use log::*; use serial_test::serial; use testcontainers::images::generic::GenericImage; use testcontainers::*; use tokio::time; use tornado_...
code_fim
hard
{ "lang": "rust", "repo": "Toure/tornado", "path": "/tornado/common/tests/nats_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let auth = Some(NatsClientAuth::Tls { path_to_pkcs12_bundle: "./test_resources/nats-client.pfx".to_string(), path_to_root_certificate: Some("./test_resources/root-ca.crt".to_string()), pkcs12_bundle_password: "".to_string(), }); subscribe_to_nats( NatsSubscriber...
code_fim
hard
{ "lang": "rust", "repo": "Toure/tornado", "path": "/tornado/common/tests/nats_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flower-os/flower path: /kernel/src/drivers/keyboard/keymap.rs #[allow(dead_code)] // Dead variants for completeness pub mod codes { //! # Codes //! //! This module contains a list of US QWERTY key code constants, based around rows/columns on a keyboard. //! This is used because, ...
code_fim
hard
{ "lang": "rust", "repo": "flower-os/flower", "path": "/kernel/src/drivers/keyboard/keymap.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Gets the Flower keycode for the given PS/2 scanset 2 scancode pub fn get_code_ps2_set_2(scancode: u8) -> Option<u8> { match scancode { 0x01 => Some(codes::F9), 0x03 => Some(codes::F5), 0x04 => Some(codes::F3), 0x05 => Some(codes::F1), 0x06 => Some(codes::F2)...
code_fim
hard
{ "lang": "rust", "repo": "flower-os/flower", "path": "/kernel/src/drivers/keyboard/keymap.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn get_pv_generation(&mut self, eg: &f32) -> f32 { match &mut self.pv { None => 0., Some(sep_bsl_pv) => { sep_bsl_pv.step(eg) }, } } /// Calculate and return current power consumption and generation /// /// # Argument...
code_fim
hard
{ "lang": "rust", "repo": "freemooshee/EnSySim", "path": "/SystemComponentsFast/src/sep_bsl_agent.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: freemooshee/EnSySim path: /SystemComponentsFast/src/sep_bsl_agent.rs // external use pyo3::prelude::*; use log::{error}; use rand::Rng; use rand_distr::{Distribution, FisherF, Gamma}; use crate::save_e; use crate::components::pv; use crate::misc::hist_memory; #[pyclass] #[derive(Clone)] pub st...
code_fim
hard
{ "lang": "rust", "repo": "freemooshee/EnSySim", "path": "/SystemComponentsFast/src/sep_bsl_agent.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: not-an-aardvark/libtock-rs path: /src/ipc_cs/client.rs use alloc::String; use alloc::allocator::{Alloc, Layout}; use alloc::boxed::Box; use alloc::heap::Heap; use alloc::raw_vec::RawVec; use callback::CallbackSubscription; use callback::SubscribableCallback; use result::TockResult; use syscalls;...
code_fim
hard
{ "lang": "rust", "repo": "not-an-aardvark/libtock-rs", "path": "/src/ipc_cs/client.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>pub fn reserve_shared_buffer() -> Box<[u8]> { let shared_val = unsafe { Heap.alloc_zeroed(Layout::from_size_align(32, 32).unwrap()) .unwrap() }; let v = unsafe { RawVec::from_raw_parts(shared_val, 32).into_box() }; v } impl ServerHandle { pub fn share(&mut self, sh...
code_fim
hard
{ "lang": "rust", "repo": "not-an-aardvark/libtock-rs", "path": "/src/ipc_cs/client.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> fn subscribe_number(&self) -> usize { self.pid as usize } fn call_rust(&mut self, pid: usize, len: usize, _: usize) { (self.callback)(pid, len); } } pub fn reserve_shared_buffer() -> Box<[u8]> { let shared_val = unsafe { Heap.alloc_zeroed(Layout::from_size_ali...
code_fim
hard
{ "lang": "rust", "repo": "not-an-aardvark/libtock-rs", "path": "/src/ipc_cs/client.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>impl GameResource for PrimitiveResource { fn initialize(world: &mut World, progress_counter: &mut ProgressCounter) { let mut p = Self::default(); world.exec(|loader: AssetLoaderSystemData<'_, Mesh>| { p.sphere = Some( loader.load_from_data( ...
code_fim
hard
{ "lang": "rust", "repo": "piedoom/sp", "path": "/src/resources/primitive.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: piedoom/sp path: /src/resources/primitive.rs //! Create a mesh from the `Shape` enum use std::collections::HashMap; use std::fs::read_dir; use crate::components::CharacterPrefab; use amethyst::{ assets::{AssetLoaderSystemData, Handle, ProgressCounter}, ecs::World, renderer::{ ...
code_fim
hard
{ "lang": "rust", "repo": "piedoom/sp", "path": "/src/resources/primitive.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl BayerRead16 for BorderNone16BE { fn read_line(&self, r: &mut Read, dst: &mut [u16]) -> BayerResult<()> { read_exact_u16be(r, dst) } } impl BorderNone16LE { pub fn new() -> Self { BorderNone16LE } } impl BayerRead16 for BorderNone16LE { fn read_line(&s...
code_fim
hard
{ "lang": "rust", "repo": "wangds/libbayer", "path": "/src/border_none.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl BorderNone16LE { pub fn new() -> Self { BorderNone16LE } } impl BayerRead16 for BorderNone16LE { fn read_line(&self, r: &mut Read, dst: &mut [u16]) -> BayerResult<()> { read_exact_u16le(r, dst) } }<|fim_prefix|>// repo: wangds/libbayer path: /src/border_n...
code_fim
medium
{ "lang": "rust", "repo": "wangds/libbayer", "path": "/src/border_none.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wangds/libbayer path: /src/border_none.rs //! Bayer reader without any additional border logic. use std::io::Read; use ::BayerResult; use bayer::*; <|fim_suffix|>impl BorderNone8 { pub fn new() -> Self { BorderNone8 } } impl BayerRead8 for BorderNone8 { fn read_line(&self...
code_fim
medium
{ "lang": "rust", "repo": "wangds/libbayer", "path": "/src/border_none.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tsvetta/rust-grokking-algorithms path: /selection_sort.rs #[derive(Clone)] #[derive(Debug)] struct Dog { name: String, age: i8, } fn find_oldest_dog(dogs: Vec<Dog>) -> usize { let end = dogs.len() - 1; let mut oldest_dog = dogs[0].clone(); let mut oldest_dog_index = 0; for i in 0.....
code_fim
medium
{ "lang": "rust", "repo": "tsvetta/rust-grokking-algorithms", "path": "/selection_sort.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return sorted_dogs; } pub fn run() { // Vector – re-sizable array let unsorted_array = vec![ Dog { name: "Berta".to_string(), age: 4}, Dog { name: "Jessie".to_string(), age: 7}, Dog { name: "Timka".to_string(), age: 25}, Dog { name: "Cerber".to_string(), age: 30}, Dog { name: "P...
code_fim
hard
{ "lang": "rust", "repo": "tsvetta/rust-grokking-algorithms", "path": "/selection_sort.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Remove an item root.remove("b"); root.dump(&mut fork)?; assert_eq!(Root::load(&fork)?, root); base.merge(&mut fork)?; assert_eq!(Root::load(&base)?, root); Ok(()) } /// Test loading & dumping of `Article`s #[test] fn article() -> Result<()> { let mut base = WriteStore:...
code_fim
hard
{ "lang": "rust", "repo": "stencila/stencila", "path": "/rust/schema/tests/load_dump.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Add an optional property article1.options.alternate_names = Some(vec!["some name".to_string()]); article1.dump(&mut base)?; assert_eq!(Article::load(&base)?.strip(&Targets::id()), &article1); // Add some content article1.content.push(Block::Paragraph(Paragraph { content...
code_fim
hard
{ "lang": "rust", "repo": "stencila/stencila", "path": "/rust/schema/tests/load_dump.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stencila/stencila path: /rust/schema/tests/load_dump.rs use std::collections::HashMap; use common::{eyre::Result, serde_json::json}; use common_dev::pretty_assertions::assert_eq; use schema::{ Array, Article, Block, Inline, Node, Null, Object, Paragraph, Primitive, Text, TextValue, }; use...
code_fim
hard
{ "lang": "rust", "repo": "stencila/stencila", "path": "/rust/schema/tests/load_dump.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "unicode")] pub use self::box_chars::{BOX_FONTS, BOX_UNICODE}; #[cfg(feature = "unicode")] pub use self::hiragana::{HIRAGANA_FONTS, HIRAGANA_UNICODE}; #[cfg(feature = "unicode")] pub use self::misc::{MISC_FONTS, MISC_UNICODE}; #[cfg(feature = "unicode")] pub use self::sga::{SGA_FONTS, S...
code_fim
hard
{ "lang": "rust", "repo": "saibatizoku/font8x8-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: saibatizoku/font8x8-rs path: /src/lib.rs //! # 8x8 monochrome bitmap fonts for rendering //! //! This crate contains a Rust implementation of a public domain 8-bit by 8-bit font. //! //! See '../README.md`. //! //! # On the miscellanous characters included //! These characters are provided as-is...
code_fim
hard
{ "lang": "rust", "repo": "saibatizoku/font8x8-rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: philipr-za/tari path: /common/src/configuration/mod.rs //! # Configuration of tari applications //! //! Tari application consist of `common`, `base_node`, `wallet` and `application` configuration sections. //! All tari apps follow traits implemented in this crate for ease and automation, for ins...
code_fim
hard
{ "lang": "rust", "repo": "philipr-za/tari", "path": "/common/src/configuration/mod.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub use base_node_config::BaseNodeConfig; pub use collectibles_config::CollectiblesConfig; pub use merge_mining_config::MergeMiningConfig; pub use validator_node_config::ValidatorNodeConfig; pub use wallet_config::WalletConfig;<|fim_prefix|>// repo: philipr-za/tari path: /common/src/configuration/mod.rs ...
code_fim
hard
{ "lang": "rust", "repo": "philipr-za/tari", "path": "/common/src/configuration/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> Stage::Uninitialized } }<|fim_prefix|>// repo: moobaaclub/solana-fantasy-app path: /contracts/solana-fantasy-sports/src/state/structures/stage.rs //! State transition types use num_enum::TryFromPrimitive; <|fim_middle|>#[repr(u8)] #[derive(Clone, Copy, Debug, PartialEq, TryFromPrimitive)] p...
code_fim
medium
{ "lang": "rust", "repo": "moobaaclub/solana-fantasy-app", "path": "/contracts/solana-fantasy-sports/src/state/structures/stage.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: moobaaclub/solana-fantasy-app path: /contracts/solana-fantasy-sports/src/state/structures/stage.rs //! State transition types use num_enum::TryFromPrimitive; <|fim_suffix|> Stage::Uninitialized } }<|fim_middle|>#[repr(u8)] #[derive(Clone, Copy, Debug, PartialEq, TryFromPrimitive)] p...
code_fim
medium
{ "lang": "rust", "repo": "moobaaclub/solana-fantasy-app", "path": "/contracts/solana-fantasy-sports/src/state/structures/stage.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: niklasad1/zcash-mmr path: /examples/producer.rs extern crate zcash_mmr as mmr; use mmr::{NodeData, Tree, EntryLink, Entry}; fn prepare_tree(vec: Vec<NodeData>) -> Tree { assert!(vec.len() > 0); // integer log2 of (vec.len()+1), -1 let mut h = (32 - ((vec.len()+1) as u32).leading_...
code_fim
hard
{ "lang": "rust", "repo": "niklasad1/zcash-mmr", "path": "/examples/producer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut initial_tree_vec = vec![ NodeData { consensus_branch_id: 0, subtree_commitment: [0u8; 32], start_time: 10, end_time: 20, start_target: 100, end_target: 110, start_sapling_root: [0u8; 32], e...
code_fim
hard
{ "lang": "rust", "repo": "niklasad1/zcash-mmr", "path": "/examples/producer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> initial_tree_vec.push( NodeData { consensus_branch_id: 0, subtree_commitment: [0u8; 32], start_time: 71, end_time: 80, start_target: 160, end_target: 170, start_sapling_root: [0u8; 32], end_sapling_...
code_fim
hard
{ "lang": "rust", "repo": "niklasad1/zcash-mmr", "path": "/examples/producer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub const SIOCADDRT: c_ulong = 0x890B; pub const SIOCDELRT: c_ulong = 0x890C; pub const SIOCRTMSG: c_ulong = 0x890D; pub const SIOCGIFNAME: c_ulong = 0x8910; pub const SIOCSIFLINK: c_ulong = 0x8911; pub const SIOCGIFCONF: c_ulong = 0x8912; pub const SIOCGIFFLAGS: c_ulong = 0x8913; pub const SIOCSIFFLAGS:...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/relibc", "path": "/src/header/sys_ioctl/linux.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub const SIOCGIFNAME: c_ulong = 0x8910; pub const SIOCSIFLINK: c_ulong = 0x8911; pub const SIOCGIFCONF: c_ulong = 0x8912; pub const SIOCGIFFLAGS: c_ulong = 0x8913; pub const SIOCSIFFLAGS: c_ulong = 0x8914; pub const SIOCGIFADDR: c_ulong = 0x8915; pub const SIOCSIFADDR: c_ulong = 0x8916; pub const SIOCGIF...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/relibc", "path": "/src/header/sys_ioctl/linux.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: redox-os/relibc path: /src/header/sys_ioctl/linux.rs use crate::platform::{types::*, Sys}; #[no_mangle] pub unsafe extern "C" fn ioctl(fd: c_int, request: c_ulong, out: *mut c_void) -> c_int { // TODO: Somehow support varargs to syscall?? Sys::ioctl(fd, request, out) } pub const TCGETS...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/relibc", "path": "/src/header/sys_ioctl/linux.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nguyenminhhieu12041996/casper-node path: /node/src/reactor/joiner.rs et block_header_and_finality_signatures_by_height_fetcher: Fetcher< BlockHeaderWithMetadata, > = Fetcher::new( "block_header_and_finality_signatures_by_height", config.fetcher, ...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/node/src/reactor/joiner.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Block validation request. #[from] BlockValidatorRequest(#[serde(skip_serializing)] BlockValidationRequest<NodeId>), /// Block proposer request. #[from] BlockProposerRequest(#[serde(skip_serializing)] BlockProposerRequest), /// Request for state storage. #[from] St...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/node/src/reactor/joiner.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Event::Storage(request.into()) } } impl From<NetworkRequest<NodeId, Message>> for Event { fn from(request: NetworkRequest<NodeId, Message>) -> Self { if env::var(ENABLE_LIBP2P_NET_ENV_VAR).is_ok() { Event::Network(network::Event::from(request)) } else { ...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/node/src/reactor/joiner.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> license_text.split(' ').map(|s| s.parse().unwrap()).collect() }<|fim_prefix|>// repo: hhawkens/advent_2018 path: /src/day_8/utils.rs use super::types::*; pub fn get_license_tree(license_text: &str) -> Tree { let license = get_license(license_text); Tree { root: Node::new(&license) } } <|fim...
code_fim
easy
{ "lang": "rust", "repo": "hhawkens/advent_2018", "path": "/src/day_8/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hhawkens/advent_2018 path: /src/day_8/utils.rs use super::types::*; pub fn get_license_tree(license_text: &str) -> Tree { let license = get_license(license_text); Tree { root: Node::new(&license) } } <|fim_suffix|> license_text.split(' ').map(|s| s.parse().unwrap()).collect() }<|fim...
code_fim
easy
{ "lang": "rust", "repo": "hhawkens/advent_2018", "path": "/src/day_8/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: frxstrem/eller path: /eller/examples/main.rs use eller::element; <|fim_suffix|> self } } fn main() { let x = element!( <Foo /> ); }<|fim_middle|>struct Foo; impl Foo { fn builder() -> Self { Foo } fn build(self) -> Self {
code_fim
medium
{ "lang": "rust", "repo": "frxstrem/eller", "path": "/eller/examples/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let x = element!( <Foo /> ); }<|fim_prefix|>// repo: frxstrem/eller path: /eller/examples/main.rs use eller::element; struct Foo; impl Foo { fn builder() -> Self { <|fim_middle|> Foo } fn build(self) -> Self { self } }
code_fim
medium
{ "lang": "rust", "repo": "frxstrem/eller", "path": "/eller/examples/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn build(self) -> Self { self } } fn main() { let x = element!( <Foo /> ); }<|fim_prefix|>// repo: frxstrem/eller path: /eller/examples/main.rs use eller::element; <|fim_middle|>struct Foo; impl Foo { fn builder() -> Self { Foo }
code_fim
medium
{ "lang": "rust", "repo": "frxstrem/eller", "path": "/eller/examples/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let buf = &*code_bytes.borrow_buf(); let code = bytecode::CodeObject::from_bytes(buf).map_err(|e| match e { bytecode::CodeDeserializeError::Eof => vm.new_exception_msg( vm.ctx.exceptions.eof_error.clone(), "end of file while deserializing bytecod...
code_fim
hard
{ "lang": "rust", "repo": "dralley/RustPython", "path": "/vm/src/stdlib/marshal.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dralley/RustPython path: /vm/src/stdlib/marshal.rs pub(crate) use decl::make_module; #[pymodule(name = "marshal")] mod decl { use crate::{ builtins::{PyBytes, PyCode}, bytecode, function::ArgBytesLike, PyObjectRef, PyResult, TryFromObject, VirtualMachine, ...
code_fim
hard
{ "lang": "rust", "repo": "dralley/RustPython", "path": "/vm/src/stdlib/marshal.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[pyfunction] fn load(f: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyCode> { let read_res = vm.call_method(&f, "read", ())?; let bytes = ArgBytesLike::try_from_object(vm, read_res)?; loads(bytes, vm) } }<|fim_prefix|>// repo: dralley/RustPython path: /vm/src/stdlib...
code_fim
hard
{ "lang": "rust", "repo": "dralley/RustPython", "path": "/vm/src/stdlib/marshal.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: szhongren/rosalind path: /fibo/src/main.rs use std::env; use std::fs::File; use std::io::Read; use std::path::PathBuf; fn main() { <|fim_suffix|> let mut data = String::new(); let _ = File::open(path) .unwrap() .read_to_string(&mut data); data } fn fibo_i(data: Strin...
code_fim
hard
{ "lang": "rust", "repo": "szhongren/rosalind", "path": "/fibo/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn fibo(i: u64) -> u64 { let mut dp: Vec<u64> = vec![0, 1]; while dp.len() < i as usize + 1 { let last = dp[dp.len() - 1]; let last_2 = dp[dp.len() - 2]; dp.push(last + last_2); } *dp.last().unwrap() }<|fim_prefix|>// repo: szhongren/rosalind path: /fibo/src/main.r...
code_fim
hard
{ "lang": "rust", "repo": "szhongren/rosalind", "path": "/fibo/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match event_pump.wait_event() { Event::Quit {..} => { running = false; } Event::MouseButtonDown {x, y, ..} => { println!("Mousesdown {},{}",x,y); } Event::KeyDown { keycode: Some(Keycode::Num1), .. } => { ...
code_fim
medium
{ "lang": "rust", "repo": "bantic/toy-rust-sudoku", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bantic/toy-rust-sudoku path: /src/main.rs extern crate sdl2; use sdl2::event::Event; use sdl2::keyboard::Keycode; pub mod render; use render::Drawer; fn main() { let width = 400; let height = 400; let sdl_context = sdl2::init().unwrap_or_else(|err| { println!("Failed to i...
code_fim
medium
{ "lang": "rust", "repo": "bantic/toy-rust-sudoku", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut running = true; while running { drawer.draw(); match event_pump.wait_event() { Event::Quit {..} => { running = false; } Event::MouseButtonDown {x, y, ..} => { println!("Mousesdown {},{}",x,y); ...
code_fim
medium
{ "lang": "rust", "repo": "bantic/toy-rust-sudoku", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fa93hws/CLRS path: /src/max_subarray/brute_force.rs pub fn find(arr: &Vec<i32>) -> i32 { let len = arr.len(); if len < 2 { return 0; } let mut max_diff = 0; let mut diff: i32; for i in 0..(len - 1) { for j in (i + 1)..len { diff = arr[j] - arr[i]; if diff > max_diff { m...
code_fim
medium
{ "lang": "rust", "repo": "fa93hws/CLRS", "path": "/src/max_subarray/brute_force.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(super::find(&vec![]), 0); assert_eq!(super::find(&vec![1]), 0); } #[test] fn simple() { assert_eq!(super::find(&vec![-5, -1, 2, 5, 1, 0, 10, -20, 5, 12, 5, 4, 9]), 32); assert_eq!(super::find(&vec![-5, -1, 2, 5, 1, 0, 10, -20, 5, 1, 5, 4, 9]), 29); assert_eq!(super::f...
code_fim
medium
{ "lang": "rust", "repo": "fa93hws/CLRS", "path": "/src/max_subarray/brute_force.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MonadKai/ruft path: /prerequisite/polars_examples/src/apply_closures.rs use polars::prelude::*; fn example() -> Series { let s: Series = Series::new("values", [Some(1.0), None, Some(3.0)]); s.f64().unwrap().apply(|v| v.powf(2.0)).into_series() } <|fim_suffix|> println!("{}", exa...
code_fim
medium
{ "lang": "rust", "repo": "MonadKai/ruft", "path": "/prerequisite/polars_examples/src/apply_closures.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: immunant/c2rust path: /c2rust-refactor/tests/ownership_upgrade_ptrs/runtime/src/lib.rs #![feature(c_variadic, extern_types, register_tool, register_attr)] #![register_tool(c2rust)] #![register_attr(nonnull)] #![register_attr(slice)] #![register_attr(ownership_constraints)] #[allow(unused_attrib...
code_fim
hard
{ "lang": "rust", "repo": "immunant/c2rust", "path": "/c2rust-refactor/tests/ownership_upgrade_ptrs/runtime/src/lib.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let mut write_data = [0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; unsafe { old::eshdn1(write_data.as_mut_ptr()); } assert_eq!(write_data, [0, 0, 0, 32769, 1, 32770, 2, 32771, 3, 32772, 4, 32773, 5]); write_data = [0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; unsafe { ...
code_fim
hard
{ "lang": "rust", "repo": "immunant/c2rust", "path": "/c2rust-refactor/tests/ownership_upgrade_ptrs/runtime/src/lib.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(write_data[9], 0x8000); write_data = [0; 10]; unsafe { new::eneg2(&mut write_data); } assert_eq!(write_data[9], 0x8000); write_data = [0; 10]; unsafe { new::eneg3(&mut write_data); } assert_eq!(write_data[9], 0x8000); } #[test] fn test_...
code_fim
hard
{ "lang": "rust", "repo": "immunant/c2rust", "path": "/c2rust-refactor/tests/ownership_upgrade_ptrs/runtime/src/lib.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if model.frames_since_tick < model.cooldown { model.frames_since_tick += 1.0; return; } let mut sample = usfx::Sample::default(); sample.osc_type(usfx::OscillatorType::Sine); sample.env_attack(0.01); sample.env_decay(0.8); sample.env_sustain(0.5); sample.en...
code_fim
hard
{ "lang": "rust", "repo": "cayal/nannou-audio-test", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..model.cells.len() { let row = model.cells[i]; let y_pos = ((CELL_DISPLAY_SIZE + CELL_DISPLAY_PADDING) * i as f32) + 0.5 * CELL_DISPLAY_PADDING - centering_bias_y; for j in 0..row.len() { let x_pos = ((CELL_DISPLAY_SIZE + CELL_DIS...
code_fim
hard
{ "lang": "rust", "repo": "cayal/nannou-audio-test", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cayal/nannou-audio-test path: /src/main.rs use cpal::traits::{EventLoopTrait, HostTrait}; use nannou::prelude::*; use rand::Rng; use std::f64::consts::PI; use std::{ sync::{Arc, Mutex}, thread, }; const MEASURE_LENGTH: usize = 16; const NOTE_RANGE: usize = 12; const CELL_DISPLAY_SIZE: ...
code_fim
hard
{ "lang": "rust", "repo": "cayal/nannou-audio-test", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let cm1 = count - 1; let mut meta = vec![LRUMeta::default(); count]; for (idx, block) in meta.iter_mut().enumerate() { if idx == 0 { block.prev = NULL; } else { block.prev = idx - 1; } if idx == cm1 { ...
code_fim
hard
{ "lang": "rust", "repo": "Vociferix/io-cache", "path": "/src/detail/replace.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vociferix/io-cache path: /src/detail/replace.rs fn new(_: usize) -> Self { let mut meta = Data::new(); for (idx, block) in meta.get_mut().iter_mut().enumerate() { if idx == 0 { block.prev = NULL; } else { block.prev = idx...
code_fim
hard
{ "lang": "rust", "repo": "Vociferix/io-cache", "path": "/src/detail/replace.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vociferix/io-cache path: /src/detail/replace.rs ize) { let back = self.back; if back != block_idx { let front = self.front; if front == block_idx { let next = self.data.get_ref()[front].next; self.front = next; ...
code_fim
hard
{ "lang": "rust", "repo": "Vociferix/io-cache", "path": "/src/detail/replace.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: williamboman/federation path: /graphql-parser/tests/helpers.rs #[macro_export] macro_rules! tests_for_parser { ($parser: ident, $name: ident, $input: expr, $expected: expr) => { paste::item! { /// test roundtrip from source with unix line endings #[test] fn [<...
code_fim
hard
{ "lang": "rust", "repo": "williamboman/federation", "path": "/graphql-parser/tests/helpers.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>use graphql_parser::{query, query::Node as QueryNode, schema, schema::Node as SchemaNode, Name}; pub fn visit_parse_query<'a>(doc: &query::Document<'a>) -> Print { let mut p = Print::default(); doc.accept(&mut p); p } pub fn visit_parse_schema<'a>(doc: &schema::Document<'a>) -> Print { l...
code_fim
hard
{ "lang": "rust", "repo": "williamboman/federation", "path": "/graphql-parser/tests/helpers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ule_inception)] mod support; pub use self::support::*;<|fim_prefix|>// repo: oshunter/fuchsia path: /third_party/rust_crates/vendor/tracing-attributes/tests/support.rs #[path = "../../tracing/tests/support/mod.rs"] // path attribute requires referenced module to have same na<|fim_middle|>me so allow modu...
code_fim
easy
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/third_party/rust_crates/vendor/tracing-attributes/tests/support.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oshunter/fuchsia path: /third_party/rust_crates/vendor/tracing-attributes/tests/support.rs #[path = "../../tracing/tests/support/mod.rs"] // pat<|fim_suffix|>ule_inception)] mod support; pub use self::support::*;<|fim_middle|>h attribute requires referenced module to have same name so allow modu...
code_fim
medium
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/third_party/rust_crates/vendor/tracing-attributes/tests/support.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub trait Unborrow { type Target; unsafe fn unborrow(self) -> Self::Target; } pub trait Steal { unsafe fn steal() -> Self; }<|fim_prefix|>// repo: rukai/embassy path: /embassy/src/util/mod.rs //! Async utilities mod critical_section; mod drop_bomb; mod forever; mod mutex; mod on_drop; mod po...
code_fim
hard
{ "lang": "rust", "repo": "rukai/embassy", "path": "/embassy/src/util/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rukai/embassy path: /embassy/src/util/mod.rs //! Async utilities mod critical_section; mod drop_bomb; mod forever; mod mutex; mod on_drop; mod portal; mod signal; #[cfg_attr(feature = "executor-agnostic", path = "waker_agnostic.rs")] mod waker; <|fim_suffix|>pub trait Unborrow { type Targe...
code_fim
medium
{ "lang": "rust", "repo": "rukai/embassy", "path": "/embassy/src/util/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: padenot/bela-sys path: /build.rs use std::env; fn main() { println!("cargo:rustc-link-lib=bela"); println!("cargo:rustc-link-lib=belaextra"); println!("cargo:rustc-link-lib=seasoc<|fim_suffix|>ustc-link-lib=modechk"); println!("cargo:rustc-link-lib=pthread"); println!("cargo...
code_fim
medium
{ "lang": "rust", "repo": "padenot/bela-sys", "path": "/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ustc-link-lib=modechk"); println!("cargo:rustc-link-lib=pthread"); println!("cargo:rustc-link-lib=rt"); println!("cargo:rustc-link-lib=stdc++"); println!("cargo:rustc-link-lib=prussdrv"); println!( "cargo:rustc-link-search=all={}/lib", env::var("CARGO_MANIFEST_DIR").unw...
code_fim
medium
{ "lang": "rust", "repo": "padenot/bela-sys", "path": "/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KrutNA/unordered-diff path: /src/main.rs use std::env as env; use std::fs::File; use std::io::Read; fn main() { let a: Vec<String>; let b: Vec<String>; let mut tmp = String::new(); match env::args().len() { 2 => { let mut file = match File::open(env::args().l...
code_fim
hard
{ "lang": "rust", "repo": "KrutNA/unordered-diff", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>read_to_string(&mut tmp).unwrap(); b = tmp.split("\n").map(|v| String::from(v)).collect::<Vec<String>>().clone(); }, _ => { panic!("Expected 1 or 2 files!") } } println!("A:\n{:?}\nB:\n{:?}", a.iter().filter(|v1| !b.iter().any(|v2| *v1 =...
code_fim
hard
{ "lang": "rust", "repo": "KrutNA/unordered-diff", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GuilloteauQ/tex-rs path: /src/expressions.rs /// File defining the structure of an expression use std::fmt; <|fim_suffix|>impl fmt::Display for Expression { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { &Expression::Str(s) => write!(f, "{}", s), ...
code_fim
medium
{ "lang": "rust", "repo": "GuilloteauQ/tex-rs", "path": "/src/expressions.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self { &Expression::Str(s) => write!(f, "{}", s), &Expression::Int(i) => write!(f, "{}", i), _ => panic!("oops"), } } }<|fim_prefix|>// repo: GuilloteauQ/tex-rs path: /src/expressions.rs /// File defining the structure of an expression use std...
code_fim
medium
{ "lang": "rust", "repo": "GuilloteauQ/tex-rs", "path": "/src/expressions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let now = Instant::now(); match run() { Ok(()) => println!("client ran successfully"), Err(e) => { println!("client failed with error {:?}", e); std::process::exit(1); } } println!("{:?}", now.elapsed()); } fn run() -> thrift::Result<()> { ...
code_fim
medium
{ "lang": "rust", "repo": "hbeimf/thrift_demo", "path": "/thrift0.11.0/rust_thrift_demo/src/bin/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn run() -> thrift::Result<()> { // build our client and connect to the host:port let mut c = TTcpChannel::new(); c.open("127.0.0.1:9999")?; let (i_chan, o_chan) = c.split()?; // build the input/output protocol let i_prot = TCompactInputProtocol::new(TFramedReadTransport::new(i_ch...
code_fim
hard
{ "lang": "rust", "repo": "hbeimf/thrift_demo", "path": "/thrift0.11.0/rust_thrift_demo/src/bin/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }