text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/arc062/src/bin/d.rs use proconio::input; use proconio::marker::Chars; <|fim_suffix|> input! { s: Chars, }; let mut p = 0; let mut c = 'g'; for i in s { match (i, c) { ('g', 'g') => p += 0, ...
code_fim
easy
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/arc062/src/bin/d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_encode_decode_contract_number() { let numbers = vec![ // left is source number, right is expected encoded array (0i64, vec![]), (1, vec![1]), (-1, vec![129]), (40, vec![40]), (-40, vec![168]), ...
code_fim
hard
{ "lang": "rust", "repo": "smartdev0218/atomicDEX-API", "path": "/mm2src/coins/qrc20/script_pubkey.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: smartdev0218/atomicDEX-API path: /mm2src/coins/qrc20/script_pubkey.rs use super::*; /// Generate a script_pubkey contains a `function_call` from the specified `contract_address`. /// The `contract_address` can be either Token address (QRC20) or Swap contract address (EtomicSwap). pub fn generat...
code_fim
hard
{ "lang": "rust", "repo": "smartdev0218/atomicDEX-API", "path": "/mm2src/coins/qrc20/script_pubkey.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { let tx = tx.clone(); let config = config.clone(); std::thread::spawn(move || { let mut ui = RfidUI::new(&config); ui.run(tx); }); } loop { let command = rx.recv().unwrap(); println!("Recv command: {:?}", command); ...
code_fim
hard
{ "lang": "rust", "repo": "benzaita/yotibox", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> env_logger::init(); let config = JsonConfig::new(std::path::Path::new("yotibox.json")); let audio_repo_base_dir: PathBuf = std::path::PathBuf::from(config.audio_base_dir().unwrap()); let audio_repo = SimpleAudioRepository::new(audio_repo_base_dir); let audio_player = SimpleAudioPlayer...
code_fim
medium
{ "lang": "rust", "repo": "benzaita/yotibox", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: benzaita/yotibox path: /src/main.rs mod adapters; mod core; mod ui; use crate::adapters::config::JsonConfig; use crate::adapters::SimpleAudioPlayer; use crate::adapters::SimpleAudioRepository; use crate::core::config::Config; use crate::core::Command; use crate::core::Controller; use crate::ui:...
code_fim
hard
{ "lang": "rust", "repo": "benzaita/yotibox", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match message { Message::Close => self.close_requested = true, Message::Execute(request) => self.begin_request(request)?, Message::UnpauseRead(token) => { if let Some(request) = self.requests.get(&token) { if let Err(e) = requ...
code_fim
hard
{ "lang": "rust", "repo": "sagebind/isahc", "path": "/src/agent/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sagebind/isahc path: /src/agent/mod.rs x; self } pub(crate) fn max_connections_per_host(mut self, max: usize) -> Self { self.max_connections_per_host = max; self } pub(crate) fn connection_cache_size(mut self, size: usize) -> Self { self.connecti...
code_fim
hard
{ "lang": "rust", "repo": "sagebind/isahc", "path": "/src/agent/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } #[tracing::instrument(level = "trace", skip(self))] fn handle_message(&mut self, message: Message) -> Result<(), Error> { tracing::trace!("received message from agent handle"); match message { Message::Close => self.close_requested = true, ...
code_fim
hard
{ "lang": "rust", "repo": "sagebind/isahc", "path": "/src/agent/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>nput;{:#?}", each_input.as_bytes()); total_input.push(each_input.trim().to_string()); print!(" > "); io::stdout().flush().unwrap(); } } Err(_e) => break 'outmost, ...
code_fim
hard
{ "lang": "rust", "repo": "wwsheng009/abcsql", "path": "/abcsql-main/src/abcsql/applic_folder/go_talk.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>matches(sep); total_input.push(last_input.to_string()); total_input.push(";".to_string()); eprintln!("{:?}", total_input.join(" ")); go_exec(x_how.clone(), total_input.join(" "), seen); ...
code_fim
hard
{ "lang": "rust", "repo": "wwsheng009/abcsql", "path": "/abcsql-main/src/abcsql/applic_folder/go_talk.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wwsheng009/abcsql path: /abcsql-main/src/abcsql/applic_folder/go_talk.rs use crate::applic_folder::compileargs::*; use crate::applic_folder::go_exec::go_exec; use std::io::{self, Write}; use std::rc::Rc; /***************************************************/ pub fn go_talk(how: HowToOpenStorage,...
code_fim
hard
{ "lang": "rust", "repo": "wwsheng009/abcsql", "path": "/abcsql-main/src/abcsql/applic_folder/go_talk.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn get_transparency_factor(&self) -> Option<f32>; }<|fim_prefix|>// repo: Gawaboumga/rustracer path: /src/raytracer/geometry.rs use super::color::Color; use super::ray::Ray; use super::vec3::Vec3; #[derive(Copy, Clone, Debug)] pub struct HitInfo { pub position: Vec3, pub normal: Vec3, } pu...
code_fim
hard
{ "lang": "rust", "repo": "Gawaboumga/rustracer", "path": "/src/raytracer/geometry.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn get_transparency_factor(&self) -> Option<f32>; }<|fim_prefix|>// repo: Gawaboumga/rustracer path: /src/raytracer/geometry.rs use super::color::Color; use super::ray::Ray; use super::vec3::Vec3; #[derive(Copy, Clone, Debug)] pub struct HitInfo { pub position: Vec3, pub normal: Vec3, } pub...
code_fim
medium
{ "lang": "rust", "repo": "Gawaboumga/rustracer", "path": "/src/raytracer/geometry.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Gawaboumga/rustracer path: /src/raytracer/geometry.rs use super::color::Color; use super::ray::Ray; use super::vec3::Vec3; #[derive(Copy, Clone, Debug)] pub struct HitInfo { pub position: Vec3, pub normal: Vec3, } pub trait Geometry: Sync + Send { fn compute_hit( <|fim_suffix|> ...
code_fim
medium
{ "lang": "rust", "repo": "Gawaboumga/rustracer", "path": "/src/raytracer/geometry.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn multiline_message_trailing_newline() { let test_name = random_name("multiline_message_trailing_newline"); libsystemd::logging::journal_send( Priority::Info, "A trailing newline\n", vec![("TEST_NAME", test_name.as_str())].into_iter(), ) .unwrap(); let...
code_fim
hard
{ "lang": "rust", "repo": "lucab/libsystemd-rs", "path": "/tests/journal.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lucab/libsystemd-rs path: /tests/journal.rs use std::process::Command; use libsystemd::logging::Priority; use rand::distributions::Alphanumeric; use rand::Rng; use std::collections::HashMap; use std::time::Duration; fn random_name(prefix: &str) -> String { format!( "{}_{}", ...
code_fim
hard
{ "lang": "rust", "repo": "lucab/libsystemd-rs", "path": "/tests/journal.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn aggregate_prices_str(results: Vec<String>) -> String { let mut symbols: HashMap<String, Vec<String>> = HashMap::new(); let mut symbol_vec: Vec<String> = Vec::new(); let mut inputs: Vec<Input> = Vec::new(); for result in results { let price_data_result: Result<Vec<Input>, StdErro...
code_fim
hard
{ "lang": "rust", "repo": "ducphamle2/Hust-Thesis", "path": "/smart-contracts/price/oscript_price_special/src/contract.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ducphamle2/Hust-Thesis path: /smart-contracts/price/oscript_price_special/src/contract.rs use std::collections::HashMap; use std::num::ParseIntError; use std::ops::Add; use crate::error::ContractError; use crate::msg::{HandleMsg, InitMsg, Input, Output, QueryMsg}; use crate::state::{config, con...
code_fim
hard
{ "lang": "rust", "repo": "ducphamle2/Hust-Thesis", "path": "/smart-contracts/price/oscript_price_special/src/contract.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GadgeurX/MapTSServer path: /src/server/mod.rs use std::thread; use std::thread::JoinHandle; use std::net::{TcpListener, TcpStream, Shutdown}; use std::io::{Read, Write}; use crate::schema_generated::packet::get_root_as_packet; use std::sync::{Arc, Mutex}; use crate::server::client::Client; use s...
code_fim
hard
{ "lang": "rust", "repo": "GadgeurX/MapTSServer", "path": "/src/server/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn run(&self, packet_processor: Arc<PacketProcessor>, game_rx: Receiver<PacketTransfer>, server_tx: Sender<PacketTransfer>) -> JoinHandle<()> { let clients = self.clients.clone(); let clients_bridge = self.clients.clone(); thread::spawn(move || { while match gam...
code_fim
hard
{ "lang": "rust", "repo": "GadgeurX/MapTSServer", "path": "/src/server/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let client = Box::new(Client::new(stream, packet_processor)); client.run(server_tx); clients.push(client) } pub fn run(&self, packet_processor: Arc<PacketProcessor>, game_rx: Receiver<PacketTransfer>, server_tx: Sender<PacketTransfer>) -> JoinHandle<()> { let clien...
code_fim
hard
{ "lang": "rust", "repo": "GadgeurX/MapTSServer", "path": "/src/server/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SallySoul/prisma path: /src/channel/traits.rs //! Traits used by the color channels use crate::channel::ChannelFormatCast; use std::ops; /// The base trait for all channels pub trait ColorChannel { /// The contained type representing the channel. Format can be a wrapper around a scalar, ...
code_fim
hard
{ "lang": "rust", "repo": "SallySoul/prisma", "path": "/src/channel/traits.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Return the inner value of the channel fn value(&self) -> Self::Format; /// Return the scalar value of the channel fn scalar(&self) -> Self::Scalar; /// Construct the channel from a scalar value fn from_scalar(value: Self::Scalar) -> Self; /// Construct the channel from the...
code_fim
medium
{ "lang": "rust", "repo": "SallySoul/prisma", "path": "/src/channel/traits.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> format!("{}, by {} ({})", self.headline, self.author, self.location) } } pub struct Tweet { pub username: String, pub content: String, pub reply: bool, pub retweet: bool, } // use the default impl impl Summary for Tweet {} // item can be moved or referenced pub fn notify(ite...
code_fim
hard
{ "lang": "rust", "repo": "guihao-liang/RustLangLearn", "path": "/ch10/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.excerpt } } struct Gui<T: Copy> { x: T, } impl<T: Copy> Gui<T> { pub fn get_x(&self) -> T { self.x } } fn main() { demo_generic_func(); demo_generic_struct(); demo_trait(); let r; { r = 5; } println!("r can be assigned if it's no...
code_fim
hard
{ "lang": "rust", "repo": "guihao-liang/RustLangLearn", "path": "/ch10/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: guihao-liang/RustLangLearn path: /ch10/src/main.rs fn largest<T: PartialOrd + Copy>(list: &[T]) -> T { let mut largest = list[0]; for &item in list.iter() { if item > largest { largest = item; } } largest } fn demo_generic_func() { let number_li...
code_fim
hard
{ "lang": "rust", "repo": "guihao-liang/RustLangLearn", "path": "/ch10/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let s = tables[&fsys::DeclType::Use].to_string(); assert!(s.contains("Used")); assert!(s.contains("Capability")); assert!(s.contains("Error")); assert!(s.contains("[✓]")); assert!(s.contains("a123456789b123456789c123456789d123456789e123456789")); // No wrap....
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/developer/ffx/plugins/component/doctor/src/lib.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[fuchsia_async::run_singlethreaded(test)] async fn test_add_diagnosis_to_table_with_color_and_wrap() { let mut tables = BTreeMap::new(); let diagnosis = Diagnosis { is_error: false, decl_type: "use".to_string(), capability: "a123456789b123456789...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/developer/ffx/plugins/component/doctor/src/lib.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/developer/ffx/plugins/component/doctor/src/lib.rs found in the LICENSE file. mod diagnosis; use { crate::diagnosis::{Analysis, Diagnosis}, anyhow::{Context, Result}, errors::{ffx_bail, ffx_error}, ffx_component::{ query::get_cml_moniker_from_...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/developer/ffx/plugins/component/doctor/src/lib.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> /// Called when a local resource received an event. /// It means that some resource have tried to connect. /// The **implementator** is in charge of accepting this connection. /// The `accept_remote` must be called for each accept request in the local resource. /// Note that an accept ...
code_fim
hard
{ "lang": "rust", "repo": "eko234/message-io", "path": "/src/network/adapter.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Called when a `Remote` is created (explicity of by a listener) /// and it is not consider ready yet. /// A remote resource **is considered ready** when it is totally connected /// and can be used for writing data. /// It implies that the user has received the `Connected` or `Accep...
code_fim
hard
{ "lang": "rust", "repo": "eko234/message-io", "path": "/src/network/adapter.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eko234/message-io path: /src/network/adapter.rs use super::remote_addr::{RemoteAddr}; use super::poll::{Readiness}; use mio::event::{Source}; use std::net::{SocketAddr}; use std::io::{self}; /// High level trait to represent an adapter for a transport protocol. /// The adapter is only used to...
code_fim
hard
{ "lang": "rust", "repo": "eko234/message-io", "path": "/src/network/adapter.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/iotsitewise/src/error_meta.rs ortalError, R>> for Error where R: Send + Sync + std::fmt::Debug + 'static, { fn from(err: smithy_http::result::SdkError<crate::error::DeletePortalError, R>) -> Self { match err { smithy_http::result::SdkErr...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/iotsitewise/src/error_meta.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> err: smithy_http::result::SdkError< crate::error::GetInterpolatedAssetPropertyValuesError, R, >, ) -> Self { match err { smithy_http::result::SdkError::ServiceError { err, ..} => match err.kind { crate::error::GetInterpolatedA...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/iotsitewise/src/error_meta.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/iotsitewise/src/error_meta.rs rom<smithy_http::result::SdkError<crate::error::DeleteAccessPolicyError, R>> for Error where R: Send + Sync + std::fmt::Debug + 'static, { fn from(err: smithy_http::result::SdkError<crate::error::DeleteAccessPolicyError, R>) ->...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/iotsitewise/src/error_meta.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> while instructions.len() > next { elapsed += 4; if elapsed > instructions[next].at { let todo = &instructions[next]; match todo.type_ { Type::Lsb { frequency } => { write_lsb( &mut gameboy_state, base_address(todo.channel) + 2, f...
code_fim
hard
{ "lang": "rust", "repo": "jawline/Mimic", "path": "/src/encoded_file/playback.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jawline/Mimic path: /src/encoded_file/playback.rs use crate::clock::Clock; use crate::cpu::Cpu; use crate::encoded_file::{Instruction, Type}; use crate::machine::MachineState; use crate::memory::{GameboyState, RomChunk}; use crate::ppu::Ppu; use crate::sound::Sound; use log::info; use std::error...
code_fim
hard
{ "lang": "rust", "repo": "jawline/Mimic", "path": "/src/encoded_file/playback.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn init_config() -> Conf { let config_path = "config.toml"; let contents = fs::read_to_string(config_path).expect("Something went wrong reading the file"); let config: Conf = toml::from_str(&contents).unwrap(); debug!("{:?}", config); config } fn main() { SimpleLogger::new().init(...
code_fim
medium
{ "lang": "rust", "repo": "fengshux/webdav", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fengshux/webdav path: /src/main.rs #[macro_use] extern crate serde_derive; extern crate toml; #[macro_use] extern crate log; extern crate use simple_logger; mod webdav; use simple_logger::SimpleLogger; use std::fs; use webdav::{Webdav, Native, Account}; #[derive(Deserialize, Debug)] struct C...
code_fim
hard
{ "lang": "rust", "repo": "fengshux/webdav", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ducktail/aoj path: /vol05/rust/q0537.rs fn main(){ loop { let nms: Vec<usize> = read_vec(); let n = nms[0]; let m = nms[1]; let s = nms[2]; if n == 0 && m == 0 && s == 0 { break; } <|fim_suffix|>where T: std::str::FromStr, T::Err: std::fmt::Deb...
code_fim
hard
{ "lang": "rust", "repo": "ducktail/aoj", "path": "/vol05/rust/q0537.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PinkDiamond1/cfb path: /tests/common/table_field_builder.rs //! This file is auto-generated by cfbc. pub mod example { #![allow(unused_imports, clippy::large_enum_variant)] use cfb::builder::{ Builder, Component, DesignatedComponent, NestedBufferComponent, ReferenceVectorCompone...
code_fim
hard
{ "lang": "rust", "repo": "PinkDiamond1/cfb", "path": "/tests/common/table_field_builder.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(Default, Clone, Debug, PartialEq)] pub struct Stat { pub hp: u32, } impl Stat { const VT_HP: usize = 4; const SIZE_HP: usize = 4; const ALIGNMENT_HP: usize = 4; const ALIGNMENT: usize = 4; } impl<'c> Component<'c> for Stat { ...
code_fim
hard
{ "lang": "rust", "repo": "PinkDiamond1/cfb", "path": "/tests/common/table_field_builder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn parse_command(args: &String) -> CliCommand { match &args.as_str() { &"help" | &"h" => CliCommand::Help, &"hello" => CliCommand::Hello, &"rangesum" => CliCommand::Rangesum, &"factorial" => CliCommand::Factorial, &"notes" | &"n" => CliCommand::No...
code_fim
hard
{ "lang": "rust", "repo": "maxgmr/multitool", "path": "/src/cli.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match cli.command { CliCommand::Empty => err::empty(), CliCommand::Unknown => err::unknown(), CliCommand::Edit => edit::edit(), CliCommand::Help => cmd::help(), CliCommand::Hello => cmd::hello(cli.args), CliCommand::Rangesum => cmd...
code_fim
medium
{ "lang": "rust", "repo": "maxgmr/multitool", "path": "/src/cli.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maxgmr/multitool path: /src/cli.rs use crate::cmd; use crate::err; use crate::edit; pub enum CliCommand { Empty, Unknown, Help, Hello, Rangesum, Factorial, Notes, Sum, Edit, } pub struct Cli { command: CliCommand, args: Option<Vec<String>> } impl C...
code_fim
hard
{ "lang": "rust", "repo": "maxgmr/multitool", "path": "/src/cli.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use server::Server; pub use shared::client::Client; pub use store::{Store,DataStore};<|fim_prefix|>// repo: viperscape/stratis path: /server/src/lib.rs extern crate postgres; extern crate uuid; extern crate stratis_shared as shared; <|fim_middle|>mod server; mod distributor; mod store;
code_fim
easy
{ "lang": "rust", "repo": "viperscape/stratis", "path": "/server/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: viperscape/stratis path: /server/src/lib.rs extern crate postgres; extern crate uuid; extern crate stratis_shared as shared; <|fim_suffix|>pub use server::Server; pub use shared::client::Client; pub use store::{Store,DataStore};<|fim_middle|>mod server; mod distributor; mod store;
code_fim
easy
{ "lang": "rust", "repo": "viperscape/stratis", "path": "/server/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ashtkn/learning-rust-language path: /samplecli/src/main.rs // use std::env; // use clap::{App, Arg}; use clap::Clap; #[derive(Clap, Debug)] #[clap( name = "My RPN program", version = "1.0.0", author = "Example Name", about = "Super awesome sample RPN calculator" )] struct Opts {...
code_fim
hard
{ "lang": "rust", "repo": "ashtkn/learning-rust-language", "path": "/samplecli/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sria91-rlox/clox-rust path: /src/opcodes.rs #[derive(Clone, Copy, PartialEq, Debug)] #[repr(u8)] pub enum OpCode { Constant, LongConstant, Closure, LongClosure, DefineGlobal, DefineLongGlobal, GetGlobal, GetLongGlobal, <|fim_suffix|> Nop, } impl From<u8> f...
code_fim
hard
{ "lang": "rust", "repo": "sria91-rlox/clox-rust", "path": "/src/opcodes.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Negate, Not, True, False, Nil, Nop, } impl From<u8> for OpCode { fn from(byte: u8) -> Self { if byte > OpCode::Nop as u8 { panic!("invalid opcode"); } unsafe { std::mem::transmute(byte) } } } impl From<OpCode> for u8 { fn from(opc...
code_fim
hard
{ "lang": "rust", "repo": "sria91-rlox/clox-rust", "path": "/src/opcodes.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>>:<none>" == image.RepoTags[0] { println!("deleting image {}", image.Id); docker.images().get(&image.Id[..]).delete().unwrap(); } else { println!("all clear"); } } sleep_ms(5000); } }<|fim_prefix|>// repo: softprops/deckhand path: /src/main.rs extern crate sh...
code_fim
medium
{ "lang": "rust", "repo": "softprops/deckhand", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: softprops/deckhand path: /src/main.rs extern crate shiplift; use shiplift::Docker; use std::thread::sleep_ms; pub fn main() { let mut docker = Docke<|fim_suffix|>>:<none>" == image.RepoTags[0] { println!("deleting image {}", image.Id); docker.images().get(&image.Id[..]).delet...
code_fim
medium
{ "lang": "rust", "repo": "softprops/deckhand", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ge.Id[..]).delete().unwrap(); } else { println!("all clear"); } } sleep_ms(5000); } }<|fim_prefix|>// repo: softprops/deckhand path: /src/main.rs extern crate shiplift; use shiplift::Docker; use std::thread::sleep_ms; pub fn main() { let mut docker = Docker::new(); loo...
code_fim
medium
{ "lang": "rust", "repo": "softprops/deckhand", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self { Number::Undefined => Number::Undefined, Number::Integer(n) => n.add_number(number), Number::Rational(q) => q.add_number(number), Number::Real(r) => r.add_number(number), Number::Complex(c) => c.add_number(number), } ...
code_fim
hard
{ "lang": "rust", "repo": "nilsmartel/number", "path": "/src/number/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nilsmartel/number path: /src/number/mod.rs use num_complex::Complex; use num_rational::Rational64; #[derive(Copy, Clone, Debug)] pub enum Number { Undefined, Integer(i64), Rational(Rational64), Real(f64), Complex(Complex<f64>), } impl Number { pub fn new_integer(value: ...
code_fim
hard
{ "lang": "rust", "repo": "nilsmartel/number", "path": "/src/number/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Struct tuple let black_tuple = ColorTuple(0, 0, 0); let origin = PointTuple(0, 0, 0); let black = Color { red: 0, blue: 0, green: 0, }; // NewType pattern struct Inches(i32); let length = Inches(10); let Inches(integer_length) = length; p...
code_fim
medium
{ "lang": "rust", "repo": "maxence-ho/learning_rust", "path": "/structs/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maxence-ho/learning_rust path: /structs/src/main.rs fn main() { let origin = Point { x: 0, y: 0 }; println!("The origin is at ({}, {})", origin.x, origin.y); let mut point = Point { x: 0, y: 0 }; point.x = 5; println!("The origin is at ({}, {})", point.x, point.y); // R...
code_fim
medium
{ "lang": "rust", "repo": "maxence-ho/learning_rust", "path": "/structs/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Update syntax let mut point = Point3d { x: 0, y: 0, z: 0 }; point = Point3d { y: 1, ..point }; // Struct tuple let black_tuple = ColorTuple(0, 0, 0); let origin = PointTuple(0, 0, 0); let black = Color { red: 0, blue: 0, green: 0, }; // NewT...
code_fim
medium
{ "lang": "rust", "repo": "maxence-ho/learning_rust", "path": "/structs/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Big5 and HKSCS. /// /// From the Encoding Standard: /// /// > This matches the Big5 standard /// > in combination with the Hong Kong Supplementary Character Set and other common extensions. pub mod big5;<|fim_prefix|>// repo: CryZe/libtww path: /crates/encoding/src/index/tradchinese/lib.rs // This is...
code_fim
medium
{ "lang": "rust", "repo": "CryZe/libtww", "path": "/crates/encoding/src/index/tradchinese/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CryZe/libtww path: /crates/encoding/src/index/tradchinese/lib.rs // This is a part of rust-encoding. // // Any copyright is dedicated to the Public Domain. // https://creativecommons.org/publicdomain/zero/1.0/ //! Traditional Chinese index tables for //! [rust-encoding](https://github.com/lifth...
code_fim
medium
{ "lang": "rust", "repo": "CryZe/libtww", "path": "/crates/encoding/src/index/tradchinese/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub state_count: u32, //pub data: HashMap<u32, Box<dyn Model>>, //pub handlers: HashMap<i32, Box<dyn View>>, } impl Context { pub fn remove(&mut self, entity: Entity) { let delete_list = entity.branch_iter(&self.tree).collect::<Vec<_>>(); for entity in delete_list.it...
code_fim
hard
{ "lang": "rust", "repo": "Frando/VIZIA", "path": "/src/context.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Frando/VIZIA path: /src/context.rs use std::{any::TypeId, collections::{HashMap, VecDeque}, rc::Rc, sync::Arc}; use crate::{CachedData, Entity, Event, IdManager, ModelData, MouseState, State, StateData, StateID, Style, Tree, TreeExt, ViewHandler}; pub struct Context { pub entity_manager:...
code_fim
hard
{ "lang": "rust", "repo": "Frando/VIZIA", "path": "/src/context.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn default_page(&self) -> &str { &self.default_page } } impl Default for HttpServerConf { fn default() -> Self { let dir = std::env::current_dir().expect("Valid current directory path"); Self::new("127.0.0.1".to_owned(), 8001, dir, "index.html".to_owned()) } }<...
code_fim
hard
{ "lang": "rust", "repo": "kirinthos/jhttp", "path": "/src/conf.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn port(&self) -> u32 { self.port } pub fn server_dir(&self) -> &Path { &self.server_dir } pub fn default_page(&self) -> &str { &self.default_page } } impl Default for HttpServerConf { fn default() -> Self { let dir = std::env::current_dir...
code_fim
medium
{ "lang": "rust", "repo": "kirinthos/jhttp", "path": "/src/conf.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kirinthos/jhttp path: /src/conf.rs //! Server configuration module. //! use std::net::IpAddr; use std::path::Path; use std::path::PathBuf; /// StreamConf contains configuration properties of the server /// library. This describes things like the server root, data /// size limit, and other attr...
code_fim
hard
{ "lang": "rust", "repo": "kirinthos/jhttp", "path": "/src/conf.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_sum_fracts() { assert_eq!(sum_fracts(vec![]), None); assert_eq!(sum_fracts(vec![(1, 4), (1, 4)]), Some((1, 2))); assert_eq!(sum_fracts(vec![(1, 2), (1, 3), (1, 4)]), Some((13, 12))); }<|fim_prefix|>// repo: mattaschmann/codewars_rust path: /src/irr_sum_of_rationals.rs use std::cmp:...
code_fim
hard
{ "lang": "rust", "repo": "mattaschmann/codewars_rust", "path": "/src/irr_sum_of_rationals.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mattaschmann/codewars_rust path: /src/irr_sum_of_rationals.rs use std::cmp::{min,max}; fn sum_fracts(l: Vec<(i64, i64)>) -> Option<(i64, i64)> { if l.is_empty() { return None; } let (large_n, large_d) = l.iter().fold((0, 1), |(x, y), &(n, d)| { let new_n = (x * d) + (n * y); let ne...
code_fim
medium
{ "lang": "rust", "repo": "mattaschmann/codewars_rust", "path": "/src/irr_sum_of_rationals.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct EventReader<R: Read + Seek>(EventReaderInner<R>); enum EventReaderInner<R: Read + Seek> { Uninitialized(Option<R>), Xml(xml::EventReader<R>), Binary(binary::EventReader<R>), } impl<R: Read + Seek> EventReader<R> { pub fn new(reader: R) -> EventReader<R> { EventReader(E...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/third_party/rust_crates/vendor/plist/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let event_reader = match EventReader::is_binary(&mut reader) { Ok(true) => EventReaderInner::Binary(binary::EventReader::new(reader)), Ok(false) => EventReaderInner::Xml(xml::EventReader::new(reader)), Err(err) => { ::std::mem::replace(&mut self....
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/third_party/rust_crates/vendor/plist/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: winksaville/fuchsia path: /third_party/rust_crates/vendor/plist/src/lib.rs //! # Plist //! //! A rusty plist parser. //! //! ## Usage //! //! Put this in your `Cargo.toml`: //! //! ```toml //! [dependencies] //! plist = "0.2" //! ``` //! //! And put this in your crate root: //! //! ```rust //! e...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/third_party/rust_crates/vendor/plist/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> vec![ 1384, 1396, 1072, 1903, 1387, 1763, 1600, 1862, 1992, 1585, 1909, 1352, 1288, 1910, 1070, 1421, 1802, 1669, 1059, 1235, 1854, 1722, 1275, 198, 1476, 1588, 1708, 1217, 1596, 1355, 1566, 1973, 1335, 1480, 1115, 1272, 1998, 1821, 2007, 1721, 1885, 1420, 1412, 1487, 1...
code_fim
hard
{ "lang": "rust", "repo": "mplanchard/aoc_2020", "path": "/src/day1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mplanchard/aoc_2020 path: /src/day1.rs struct PairIterator { vec: Vec<usize>, i_idx: usize, j_idx: usize, } impl PairIterator { fn new(vec: Vec<usize>) -> Self { Self { vec, i_idx: 0, j_idx: 0, } } } impl Iterator for PairIt...
code_fim
hard
{ "lang": "rust", "repo": "mplanchard/aoc_2020", "path": "/src/day1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>trait Pairs { /// Return a lazy iterator over unique pairs from the vec fn pairs(self) -> PairIterator; } impl Pairs for Vec<usize> { /// Return a lazy iterator over unique pairs from the vec fn pairs(self) -> PairIterator { PairIterator::new(self) } } trait Triads { /// R...
code_fim
hard
{ "lang": "rust", "repo": "mplanchard/aoc_2020", "path": "/src/day1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: galaali/trashy_bot path: /src/commands.rs pub mod about; pub mod account; pub mod choose; pub mod config; pub mod copypasta; pub mod <|fim_suffix|>od poll; pub mod selfmute; pub mod shiny; pub mod spongebob; pub mod userinfo; pub mod xkcd;<|fim_middle|>emoji; pub mod fav; pub mod groups; pub mod...
code_fim
medium
{ "lang": "rust", "repo": "galaali/trashy_bot", "path": "/src/commands.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> mod quote; pub mod reaction_roles; pub mod remindme; pub mod roll; // pub mod rules; pub mod poll; pub mod selfmute; pub mod shiny; pub mod spongebob; pub mod userinfo; pub mod xkcd;<|fim_prefix|>// repo: galaali/trashy_bot path: /src/commands.rs pub mod about; pub mod account; pub mod choose; pub mod c...
code_fim
medium
{ "lang": "rust", "repo": "galaali/trashy_bot", "path": "/src/commands.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zzzzzhang989/Operating-system-experiment path: /user/src/bin/forktree.rs #![no_std] #![no_main] #[macro_use] extern crate user_lib; use user_lib::{sleep, getpid, fork, exit, yield_}; const DEPTH: usize = 4; <|fim_suffix|> println!("pid{}: {}", getpid(), cur); fork_child(cur, '0'); ...
code_fim
hard
{ "lang": "rust", "repo": "zzzzzhang989/Operating-system-experiment", "path": "/user/src/bin/forktree.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut next = [0u8; DEPTH + 1]; let l = cur.len(); if l >= DEPTH { return; } next[..l].copy_from_slice(cur.as_bytes()); next[l] = branch as u8; if fork() == 0 { fork_tree(core::str::from_utf8(&next[..l + 1]).unwrap()); yield_(); exit(0); } }...
code_fim
medium
{ "lang": "rust", "repo": "zzzzzhang989/Operating-system-experiment", "path": "/user/src/bin/forktree.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Giovan/lumen path: /lumen_runtime/src/otp/timer/tc_3/label_5.rs use std::sync::Arc; use liblumen_alloc::erts::exception::system::Alloc; use liblumen_alloc::erts::process::code::stack::frame::{Frame, Placement}; use liblumen_alloc::erts::process::{code, Process}; use liblumen_alloc::erts::term::...
code_fim
medium
{ "lang": "rust", "repo": "Giovan/lumen", "path": "/lumen_runtime/src/otp/timer/tc_3/label_5.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mvertescher/hostap-rs path: /src/core.rs //! Core softap interface management <|fim_suffix|>pub fn pkill(process: &str) { Command::new("pkill") .arg("-9") .arg(process) .output() .expect("failed to execute process"); }<|fim_middle|>use std::process::Command; ...
code_fim
easy
{ "lang": "rust", "repo": "mvertescher/hostap-rs", "path": "/src/core.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn pkill(process: &str) { Command::new("pkill") .arg("-9") .arg(process) .output() .expect("failed to execute process"); }<|fim_prefix|>// repo: mvertescher/hostap-rs path: /src/core.rs //! Core softap interface management <|fim_middle|>use std::process::Command; ...
code_fim
easy
{ "lang": "rust", "repo": "mvertescher/hostap-rs", "path": "/src/core.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "look-ahead")] fn load_prebuilt_data<Imp>(root: &Path, imp: &Imp) -> Result<PrebuiltData<Imp::PrebuiltCode>> where Imp: SourceTrait, { let path = root.join(PATH_CACHE_PREBUILT); if path.exists() { let file = File::open(path)?; Ok(PrebuiltData { inner...
code_fim
hard
{ "lang": "rust", "repo": "podo-os/sos-client", "path": "/src/source/cache_yes.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: podo-os/sos-client path: /src/source/cache_yes.rs use std::fs::File; use std::path::Path; use super::base::SourceTrait; #[cfg(feature = "look-ahead")] use super::look_ahead_yes::PrebuiltData; use super::root::SourceRoot; use crate::error::*; use serde::{de::DeserializeOwned, Serialize}; const...
code_fim
hard
{ "lang": "rust", "repo": "podo-os/sos-client", "path": "/src/source/cache_yes.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let path = root.join(PATH_CACHE); if path.exists() { let file = File::open(path)?; Ok(Self { #[cfg(feature = "look-ahead")] prebuilt: load_prebuilt_data(root, &imp)?, root: root.to_owned(), stack: Vec::...
code_fim
hard
{ "lang": "rust", "repo": "podo-os/sos-client", "path": "/src/source/cache_yes.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stormtracks/rust-examples path: /sqlite/examples/ex00.rs use rusqlite::{Connection, Result}; fn main() -> Result<()> { <|fim_suffix|> conn.execute( "create table if not exists cat_colors ( id integer primary key, name text not null unique )", ...
code_fim
medium
{ "lang": "rust", "repo": "stormtracks/rust-examples", "path": "/sqlite/examples/ex00.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> conn.execute( "create table if not exists cat_colors ( id integer primary key, name text not null unique )", [], )?; conn.execute( "create table if not exists cats ( id integer primary key, name text not null,...
code_fim
medium
{ "lang": "rust", "repo": "stormtracks/rust-examples", "path": "/sqlite/examples/ex00.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>SYS_RESTART_SYSCALL).map(|ret| ret as i32) }<|fim_prefix|>// repo: XuShaohua/nc path: /src/calls/restart_syscall.rs /// Restart a system call after interruption by a stop signal. pub unsafe fn restart_sys<|fim_middle|>call() -> Result<i32, Errno> { syscall0(
code_fim
easy
{ "lang": "rust", "repo": "XuShaohua/nc", "path": "/src/calls/restart_syscall.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: XuShaohua/nc path: /src/calls/restart_syscall.rs /// Restart a system call after interruption<|fim_suffix|>call() -> Result<i32, Errno> { syscall0(SYS_RESTART_SYSCALL).map(|ret| ret as i32) }<|fim_middle|> by a stop signal. pub unsafe fn restart_sys
code_fim
easy
{ "lang": "rust", "repo": "XuShaohua/nc", "path": "/src/calls/restart_syscall.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Koalab99/feather path: /server/src/joinhandler.rs //! The join handler, in contrast to the initial handler, //! takes over after the login sequence has completed. //! It's responsible for asyncrhonously loading the player's //! data (inventory, chunks, etc.) and then sending the necessary //! pa...
code_fim
hard
{ "lang": "rust", "repo": "Koalab99/feather", "path": "/server/src/joinhandler.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut holder_comp = ChunkHolderComponent::new(); let mut loaded_chunks_comp = LoadedChunksComponent::default(); // Offsets from the origin to center view distance on let chunk_offset_x = level.spawn_x >> 4; ...
code_fim
hard
{ "lang": "rust", "repo": "Koalab99/feather", "path": "/server/src/joinhandler.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut to_remove = vec![]; for (player, net, join_handler, pending_chunks) in (&entities, &netcomps, &mut joincomps, &pending_chunks).join() { match join_handler.stage { Stage::Initial => { let playercomp = playercomps.g...
code_fim
hard
{ "lang": "rust", "repo": "Koalab99/feather", "path": "/server/src/joinhandler.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>mestamp<'de, D>( deserializer: D ) -> Result<DateTime<Utc>, D::Error> where D: serde::Deserializer<'de>, { let timestamp_nano = u64::deserialize(deserializer)?; let timestamp = chrono::NaiveDateTime::from_timestamp( (timestamp_nano / 1_000_000_000) as i64, (timestamp_nano %...
code_fim
medium
{ "lang": "rust", "repo": "danieleades/shiplift", "path": "/src/datetime.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danieleades/shiplift path: /src/datetime.rs use chrono::{DateTime, Utc}; use serde::Deserialize; pub(crate) fn datetime_from_unix_timestamp<'de, D>( deserializer: D ) -> Result<DateTime<Utc>, D::Error> where D: serde::Deserializ<|fim_suffix|>hrono::NaiveDateTime::from_timestamp( ...
code_fim
hard
{ "lang": "rust", "repo": "danieleades/shiplift", "path": "/src/datetime.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DJolley12/contact_sync path: /contact_sync_service/src/models.rs use super::schema::contacts; use super::schema::emails; use super::schema::phone_numbers; use super::schema::users; use rocket_contrib::json; #[derive(Insertable, Deserialize)] #[table_name="users"] pub struct NewUser<'a> { pu...
code_fim
hard
{ "lang": "rust", "repo": "DJolley12/contact_sync", "path": "/contact_sync_service/src/models.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Insertable)] #[table_name="emails"] pub struct NewEmail<'a> { pub email_address: &'a str, pub contact_id: &'a i32, } #[derive(Queryable)] pub struct Email { pub id: i32, pub email_address: String, pub contact_id: i32, }<|fim_prefix|>// repo: DJolley12/contact_sync path: /co...
code_fim
hard
{ "lang": "rust", "repo": "DJolley12/contact_sync", "path": "/contact_sync_service/src/models.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Return the next result item from the buffer unless more data needs to be fetched. /// /// Data does not need to be fetched if the limit is reached or the buffer is empty and the /// last chunk was reached. pub(crate) fn next_raw(&mut self) -> Option<Result<Option<T>, InvocationErro...
code_fim
hard
{ "lang": "rust", "repo": "Sparkenstein/grammers", "path": "/lib/grammers-client/src/types/iter_buffer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Sparkenstein/grammers path: /lib/grammers-client/src/types/iter_buffer.rs // Copyright 2020 - developers of the `grammers` project. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https:...
code_fim
hard
{ "lang": "rust", "repo": "Sparkenstein/grammers", "path": "/lib/grammers-client/src/types/iter_buffer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Common parts to all requests that are used for creating iterators. /// /// End-users should obtain particular instances of this type via client methods. pub struct IterBuffer<R, T> { pub(crate) client: ClientHandle, pub(crate) limit: Option<usize>, pub(crate) fetched: usize, pub(crate)...
code_fim
hard
{ "lang": "rust", "repo": "Sparkenstein/grammers", "path": "/lib/grammers-client/src/types/iter_buffer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn print_node_tree(node: &Node<E, I>, depth: usize) { for _ in 0..depth { eprint!(" "); } match node { Node::Internal(n) => { let n = n.as_ref().get_ref(); eprintln!("Internal {:?} (parent: {:?})", n as *const _, n.parent); l...
code_fim
hard
{ "lang": "rust", "repo": "audreyfeldroy/diamond-types", "path": "/src/range_tree/root.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: audreyfeldroy/diamond-types path: /src/range_tree/root.rs r::PhantomPinned, }); // What a mess. I'm sure there's a nicer way to write this, somehow O_o. let parent_ref = unsafe { tree.as_ref().get_ref().to_parent_ptr() }; tree.as_mut().root_ref_mut().set_parent(p...
code_fim
hard
{ "lang": "rust", "repo": "audreyfeldroy/diamond-types", "path": "/src/range_tree/root.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }