text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let res = reqwest::Client::new() .post(&format!( "{}/api/v1/admin/add_artist", crate::API_SERVER_BASE )) .json(&body) .send() .await .unwrap() .json::<String>() .await .unwrap(); println!("{:?}", res); ...
code_fim
hard
{ "lang": "rust", "repo": "AtsukiTak/window.art", "path": "/server/artell-cli/src/add_artist.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AtsukiTak/window.art path: /server/artell-cli/src/add_artist.rs use structopt::StructOpt; /* * =========== * AddArtist * =========== */ #[derive(Debug, StructOpt)] pub struct Command { name: String, email: String, status_msg: String, description: String, instagram: Strin...
code_fim
hard
{ "lang": "rust", "repo": "AtsukiTak/window.art", "path": "/server/artell-cli/src/add_artist.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: steamroller-airmash/statsbot-log-tools-rs path: /src/bin/avgping.rs extern crate statslib; use statslib::*; use std::io::{BufReader, BufRead}; use std::fs::File; use std::env::args; use std::vec::Vec; use std::collections::HashMap; fn main() { let args: Vec<String> = args().collect(); if ...
code_fim
hard
{ "lang": "rust", "repo": "steamroller-airmash/statsbot-log-tools-rs", "path": "/src/bin/avgping.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if result.is_err() { //println!("{}", result.unwrap_err().message); continue; } let record = result.unwrap(); if record.tag == "PLAYER_DETAILED_SCORE" { let id = match record.entries["id"] { RecordValue::Int(val) => val, _ => panic!("id was not an int") }; let ping = match ...
code_fim
medium
{ "lang": "rust", "repo": "steamroller-airmash/statsbot-log-tools-rs", "path": "/src/bin/avgping.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hirohito-protagonist/snake path: /src/ui.rs extern crate piston_window; extern crate find_folder; use piston_window::*; use crate::theme; pub struct UI { width: i32, height: i32, } impl UI { pub fn new(viewport: (u32, u32)) -> UI { let (width, height) = viewport; ...
code_fim
hard
{ "lang": "rust", "repo": "hirohito-protagonist/snake", "path": "/src/ui.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> pub fn render_title(&self, context: &Context, g: &mut G2d, glyphs: &mut piston_window::glyph_cache::rusttype::GlyphCache<GfxFactory, G2dTexture>) { let transform = context.transform.trans(10.0, (self.height * 10 + 15).into()); text::Text::new_color(theme::TEXT_COLOR, 18).draw( ...
code_fim
hard
{ "lang": "rust", "repo": "hirohito-protagonist/snake", "path": "/src/ui.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> pub fn render_pause(&self, context: &Context, g: &mut G2d, glyphs: &mut piston_window::glyph_cache::rusttype::GlyphCache<GfxFactory, G2dTexture>) { let pos_x = (((self.width * 10) as f32 / 2.0) - 60.0).into(); let pos_y = (((self.height * 10) as f32 / 2.0) + 16.0).into(); let p...
code_fim
hard
{ "lang": "rust", "repo": "hirohito-protagonist/snake", "path": "/src/ui.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aleics/rxrs path: /src/tests/interval.rs use std::thread::sleep; use std::time::Duration; use crate::operators::interval; use crate::tests::utils::{is_completed, values_sent}; <|fim_suffix|> let obs = interval(1); sleep(Duration::from_millis(2)); assert!(values_sent(&obs, &[0, 1, 2...
code_fim
easy
{ "lang": "rust", "repo": "aleics/rxrs", "path": "/src/tests/interval.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> sleep(Duration::from_millis(2)); assert!(values_sent(&obs, &[0, 1, 2])); assert_eq!(is_completed(&obs), false); }<|fim_prefix|>// repo: aleics/rxrs path: /src/tests/interval.rs use std::thread::sleep; use std::time::Duration; use crate::operators::interval; use crate::tests::utils::{is_compl...
code_fim
easy
{ "lang": "rust", "repo": "aleics/rxrs", "path": "/src/tests/interval.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>test_string!(test_empty_string, ""); test_string!(test_a, "a"); test_string!(test_hello_world, "hello world"); test_string!(test_x_1024, "x".repeat(1024)); test_string!(test_x_4096, "x".repeat(4096)); test_string!(test_x_65535, "x".repeat(65535)); test_string!(test_hello_1000, "hello world!".repeat(1000))...
code_fim
hard
{ "lang": "rust", "repo": "MagicRB/borsh", "path": "/borsh-rs/borsh/tests/test_strings.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MagicRB/borsh path: /borsh-rs/borsh/tests/test_strings.rs use borsh::{BorshDeserialize, BorshSerialize}; macro_rules! test_string { ($test_name: ident, $str: expr) => { #[test] fn $test_name() { <|fim_suffix|>test_string!(test_empty_string, ""); test_string!(test_a, "a"); te...
code_fim
hard
{ "lang": "rust", "repo": "MagicRB/borsh", "path": "/borsh-rs/borsh/tests/test_strings.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: phucvin/tl_sync path: /src/threads.rs use std::thread; pub const THREADS: usize = 3; pub const MUTATE_THREAD_INDEX: usize = 2; <|fim_suffix|>pub fn thread_index() -> usize { CACHED_THREAD_INDEX.with(|c| *c) }<|fim_middle|>thread_local! { static CACHED_THREAD_INDEX: usize = match thread...
code_fim
hard
{ "lang": "rust", "repo": "phucvin/tl_sync", "path": "/src/threads.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn thread_index() -> usize { CACHED_THREAD_INDEX.with(|c| *c) }<|fim_prefix|>// repo: phucvin/tl_sync path: /src/threads.rs use std::thread; pub const THREADS: usize = 3; pub const MUTATE_THREAD_INDEX: usize = 2; <|fim_middle|>thread_local! { static CACHED_THREAD_INDEX: usize = match thread...
code_fim
hard
{ "lang": "rust", "repo": "phucvin/tl_sync", "path": "/src/threads.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// return a writable gardeners' bucket pub fn gardeners_store(storage: &mut dyn Storage) -> Bucket<Gardener> { bucket(storage, GARDENERS_KEY) } /// return a read-only gardeners' bucket pub fn gardeners_store_read(storage: &dyn Storage) -> ReadonlyBucket<Gardener> { bucket_read(storage, GARDENERS...
code_fim
hard
{ "lang": "rust", "repo": "trungthaihieu93-dev/wasm-test-contract", "path": "/src/state.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: trungthaihieu93-dev/wasm-test-contract path: /src/state.rs use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use cosmwasm_std::{CanonicalAddr, Coin, Storage}; use cosmwasm_storage::{ bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, ReadonlySingleton, ...
code_fim
hard
{ "lang": "rust", "repo": "trungthaihieu93-dev/wasm-test-contract", "path": "/src/state.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// return a writable bonsais list pub fn bonsai_store(storage: &mut dyn Storage) -> Singleton<BonsaiList> { singleton(storage, BONSAI_KEY) } /// return a read-only bonsais list pub fn bonsai_store_read(storage: &dyn Storage) -> ReadonlySingleton<BonsaiList> { singleton_read(storage, BONSAI_KEY) ...
code_fim
hard
{ "lang": "rust", "repo": "trungthaihieu93-dev/wasm-test-contract", "path": "/src/state.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// num_inversions::stress_test::run_stress_test(); // num_inversions::main::main(); closest_points::stress_test::run_stress_test(); // closest_points::main::main(); }<|fim_prefix|>// repo: osheari1/data-struct-and-algo path: /course1/rust-slns/src/week4/src/main.rs #![allow(unused_imports)] ...
code_fim
medium
{ "lang": "rust", "repo": "osheari1/data-struct-and-algo", "path": "/course1/rust-slns/src/week4/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: osheari1/data-struct-and-algo path: /course1/rust-slns/src/week4/src/main.rs #![allow(unused_imports)] #![allow(unused_variables)] #![allow(dead_code)] extern crate core; <|fim_suffix|>// num_inversions::stress_test::run_stress_test(); // num_inversions::main::main(); closest_points::...
code_fim
medium
{ "lang": "rust", "repo": "osheari1/data-struct-and-algo", "path": "/course1/rust-slns/src/week4/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/measureme path: /analyzeme/src/analysis.rs ver the profiling data. As the algorithm walks the /// data, it needs to keep track of invocation stacks. Because interval events /// occur in the stream at their "end" time, a parent event comes after all /// child events. For thi...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/measureme", "path": "/analyzeme/src/analysis.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn same_event_multiple_times() { // <--e3--> <--e3--> // <---e2---> <---e2---> // <--------e1--------><--------e1--------> // 100 200 300 let mut b = ProfilingDataBuilder::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/measureme", "path": "/analyzeme/src/analysis.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: michalisioak/aries-vcx path: /libvcx/src/aries/handlers/issuance/holder/holder.rs use std::collections::HashMap; use crate::aries::handlers::issuance::holder::state_machine::HolderSM; use crate::aries::handlers::issuance::messages::CredentialIssuanceMessage; use crate::aries::messages::a2a::A2A...
code_fim
hard
{ "lang": "rust", "repo": "michalisioak/aries-vcx", "path": "/libvcx/src/aries/handlers/issuance/holder/holder.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn send_request(&mut self, connection_handle: u32) -> VcxResult<()> { self.step(CredentialIssuanceMessage::CredentialRequestSend(), connection_handle) } pub fn is_terminal_state(&self) -> bool { self.holder_sm.is_terminal_state() } pub fn find_message_to_handle(&s...
code_fim
hard
{ "lang": "rust", "repo": "michalisioak/aries-vcx", "path": "/libvcx/src/aries/handlers/issuance/holder/holder.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_tails_hash(&self) -> VcxResult<String> { self.holder_sm.get_tails_hash() } pub fn get_rev_reg_id(&self) -> VcxResult<String> { self.holder_sm.get_rev_reg_id() } pub fn delete_credential(&self) -> VcxResult<()> { self.holder_sm.delete_credential() ...
code_fim
hard
{ "lang": "rust", "repo": "michalisioak/aries-vcx", "path": "/libvcx/src/aries/handlers/issuance/holder/holder.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: testcc2c/kernel-rs path: /driver/src/dispatch/handler.rs use crate::dispatch::types::{Request, Response}; use crate::kernel::{KernelError, Process}; impl Request<'_> { pub fn handle(&mut self) -> Result<Response, KernelError> { Ok(match self { Request::ModuleInfo(p<|fim_...
code_fim
hard
{ "lang": "rust", "repo": "testcc2c/kernel-rs", "path": "/driver/src/dispatch/handler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>::GetProcessBitness(pid) => Response::ProcessBitness(Process::by_id(*pid)?.get_bitness()), Request::ReadMemory { address, buf, pid } => { Process::by_id(*pid)?.read_memory(*address, buf)?; Response::ReadMemory }, Request::WriteMemory { ad...
code_fim
hard
{ "lang": "rust", "repo": "testcc2c/kernel-rs", "path": "/driver/src/dispatch/handler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn is_default(&self) -> bool { self.bits == Self::DEFAULT.bits } pub fn apply_perms(protect_range: &VMRange, perms: VMPerms) { use sgx_trts::enclave::rsgx_is_supported_EDMM; unsafe { let mut retval = 0; let addr = protect_range.start() as *...
code_fim
hard
{ "lang": "rust", "repo": "occlum/occlum", "path": "/src/libos/src/vm/vm_perms.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: occlum/occlum path: /src/libos/src/vm/vm_perms.rs use super::*; bitflags! { pub struct VMPerms : u32 { const NONE = 0x0; const READ = 0x1; const WRITE = 0x2; const EXEC = 0x4; const DEFAULT = Self::READ.bits | Self::WRIT...
code_fim
hard
{ "lang": "rust", "repo": "occlum/occlum", "path": "/src/libos/src/vm/vm_perms.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> VMPerms::DEFAULT } } extern "C" { // Modify the access permissions of the pages in the reserved memory area // // Parameters: // Inputs: addr[in]: Starting address of region which needs to change access // permission. Page aligned. // length[in]: The le...
code_fim
hard
{ "lang": "rust", "repo": "occlum/occlum", "path": "/src/libos/src/vm/vm_perms.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sansare/stripe-rs path: /src/resources/refund.rs use crate::config::{Client, Response}; use crate::params::{Identifiable, List, Metadata, RangeQuery, Timestamp}; use crate::resources::Currency; use serde_derive::{Deserialize, Serialize}; /// An enum representing the possible values of a `Refund...
code_fim
hard
{ "lang": "rust", "repo": "sansare/stripe-rs", "path": "/src/resources/refund.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Retrieves the details of a refund. /// /// For more details see [https://stripe.com/docs/api/refunds/retrieve](https://stripe.com/docs/api/refunds/retrieve). pub fn retrieve(client: &Client, refund_id: &str) -> Response<Refund> { client.get(&format!("/refunds/{}", refund_id)) ...
code_fim
hard
{ "lang": "rust", "repo": "sansare/stripe-rs", "path": "/src/resources/refund.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ameobea/noise-rs path: /src/modules/generators/cylinders.rs // Copyright (c) 2017 The Noise-rs 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/M...
code_fim
hard
{ "lang": "rust", "repo": "Ameobea/noise-rs", "path": "/src/modules/generators/cylinders.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> calculate_cylinders(&point, self.frequency) } } fn calculate_cylinders<T: Float>(point: &[T], frequency: T) -> T { // Scale the inputs by the frequency. let x = point[0] * frequency; let y = point[1] * frequency; // Calculate the distance of the point from the origin. le...
code_fim
hard
{ "lang": "rust", "repo": "Ameobea/noise-rs", "path": "/src/modules/generators/cylinders.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Scale the inputs by the frequency. let x = point[0] * frequency; let y = point[1] * frequency; // Calculate the distance of the point from the origin. let dist_from_center = (x.powi(2) + y.powi(2)).sqrt(); let dist_from_smaller_sphere = dist_from_center - dist_from_center.floo...
code_fim
medium
{ "lang": "rust", "repo": "Ameobea/noise-rs", "path": "/src/modules/generators/cylinders.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ad_to_string(&mut o)?; Ok(o.trim().to_owned()) }<|fim_prefix|>// repo: sd2k/advent-of-code-2017 path: /rust-lib/src/lib.rs use std::fs::File; use std::io::{Read, Result}; pub fn get_file_to_string(f: &str) -> Result<String> { <|fim_middle|> let mut o = String::new(); File::open(f)?.re
code_fim
easy
{ "lang": "rust", "repo": "sd2k/advent-of-code-2017", "path": "/rust-lib/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sd2k/advent-of-code-2017 path: /rust-lib/src/lib.rs use std::fs::File; use std::io::{Read, Result}; pub<|fim_suffix|> let mut o = String::new(); File::open(f)?.read_to_string(&mut o)?; Ok(o.trim().to_owned()) }<|fim_middle|> fn get_file_to_string(f: &str) -> Result<String> {
code_fim
easy
{ "lang": "rust", "repo": "sd2k/advent-of-code-2017", "path": "/rust-lib/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut o = String::new(); File::open(f)?.read_to_string(&mut o)?; Ok(o.trim().to_owned()) }<|fim_prefix|>// repo: sd2k/advent-of-code-2017 path: /rust-lib/src/lib.rs use std::fs::File; use std::io::{Read, Result}; pub<|fim_middle|> fn get_file_to_string(f: &str) -> Result<String> {
code_fim
easy
{ "lang": "rust", "repo": "sd2k/advent-of-code-2017", "path": "/rust-lib/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jheloper/rust-playground path: /src/generic_example.rs pub fn example_generic() { let numbers1 = vec![34, 50, 25, 100, 65]; let result1 = largest(&numbers1); println!("The largest number is {}", result1); let numbers2 = vec![102, 34, 6000, 89, 54, 2, 43, 8]; let result2 = ...
code_fim
hard
{ "lang": "rust", "repo": "jheloper/rust-playground", "path": "/src/generic_example.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forny/advent-of-code-2020 path: /rust/day3/src/main.rs //! Solutions to 2020: Advent of Code day 3 //! By Peter Fornwall use std::fs; pub fn find(slope_map: &Vec<Vec<bool>>, delta_x: usize, delta_y: usize) -> i64 { let mut x = 0; let mut y = 0; let height = slope_map.len(); let...
code_fim
hard
{ "lang": "rust", "repo": "forny/advent-of-code-2020", "path": "/rust/day3/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let content = fs::read_to_string("../../inputs/day3_input.txt").expect("Cannot open file!"); let mut v = Vec::<Vec<bool>>::new(); for line in content.lines() { let vec_line: Vec<bool> = line .chars() .map(|c| if c == '#' { true } else { false }) .col...
code_fim
hard
{ "lang": "rust", "repo": "forny/advent-of-code-2020", "path": "/rust/day3/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // helper function for test pub fn to_list(vec: Vec<u32>) -> Option<Box<ListNode>> { let mut current = None; for &v in vec.iter().rev() { let mut node = ListNode::new(v); node.next = current; current = Some(Box::new(node)); } curr...
code_fim
hard
{ "lang": "rust", "repo": "tengrommel/leetcode_in_rust", "path": "/leetcode/2_add_two_numbers/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tengrommel/leetcode_in_rust path: /leetcode/2_add_two_numbers/main.rs struct Solution; #[derive(PartialEq, Eq, Debug)] struct ListNode { value: u32, next: Option<Box<ListNode>>, } impl ListNode { fn new(value: u32) -> Self { ListNode { value, next: None } } } impl Solu...
code_fim
hard
{ "lang": "rust", "repo": "tengrommel/leetcode_in_rust", "path": "/leetcode/2_add_two_numbers/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let span = ispan; Ok(PathSegment::Ident(AstNode::new(ident, span))) } pub fn fn_args( tokens: &mut BufferedTokenizer, ) -> ParseErr<AstNode<Option<Vec<AstNode<Expr>>>>> { let (lspan, _) = consume_token!( tokens, Token::LParen, parser_state!("fn-args", "lparen") ...
code_fim
hard
{ "lang": "rust", "repo": "InnPatron/smpl", "path": "/smpl/src/parser/expr_parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> enum SegmentDec { Dot, Indexing, End, } let (ispan, ident) = consume_token!(tokens, Token::Identifier(i) => Ident(i), parser_state!("path-segment", "name")); match peek_token!( ...
code_fim
hard
{ "lang": "rust", "repo": "InnPatron/smpl", "path": "/smpl/src/parser/expr_parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: InnPatron/smpl path: /smpl/src/parser/expr_parser.rs lt { PeekResult::Execute(op) => op, PeekResult::Break => break, }; let rhs_op_prec = bin_op_precedence(&rhs_op_peek); rhs = production!( expr(tokens, rhs, de...
code_fim
hard
{ "lang": "rust", "repo": "InnPatron/smpl", "path": "/smpl/src/parser/expr_parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // construct publish, subscribe, unsubscribe services inner .publish .new_service(&session) .map_err(|e| e.into()) .join3( inner.subscribe.new_service(&session), inner.unsubscrib...
code_fim
hard
{ "lang": "rust", "repo": "2892931976/actix-mqtt", "path": "/src/server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 2892931976/actix-mqtt path: /src/server.rs :future::{err, ok, Either, FutureResult}; use futures::unsync::mpsc; use futures::{try_ready, Async, Future, Poll, Sink, Stream}; use mqtt_codec as mqtt; use crate::cell::Cell; use crate::connect::{Connect, ConnectAck}; use crate::dispatcher::ServerDis...
code_fim
hard
{ "lang": "rust", "repo": "2892931976/actix-mqtt", "path": "/src/server.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) struct ServerInner<Io, U, S, C: Service, P, E, I> { connect: C, publish: Rc<P>, subscribe: Rc<boxed::BoxedNewService<S, Subscribe<S>, SubscribeResult, E, E>>, unsubscribe: Rc<boxed::BoxedNewService<S, Unsubscribe<S>, (), E, E>>, time: LowResTimeService, on_close: Option<...
code_fim
hard
{ "lang": "rust", "repo": "2892931976/actix-mqtt", "path": "/src/server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KallDrexx/mmids-rust path: /rtmp_message/src/rtmp_message_details.rs use std::mem; use rtmp_time::RtmpTimestamp; use errors::{MessageDeserializationError, MessageSerializationError}; use MessagePayload; use RtmpMessage; #[derive(PartialEq, Debug)] pub struct RtmpMessageDetails { pub rtmp_t...
code_fim
hard
{ "lang": "rust", "repo": "KallDrexx/mmids-rust", "path": "/rtmp_message/src/rtmp_message_details.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let details = RtmpMessageDetails { rtmp_timestamp: RtmpTimestamp::new(5), stream_id: stream_id, message: RtmpMessage::Unknown { type_id: 255, data: vec![1,2,3,4,5] } }; let expected = MessagePayload { timestamp: RtmpTimestamp::new(5)...
code_fim
hard
{ "lang": "rust", "repo": "KallDrexx/mmids-rust", "path": "/rtmp_message/src/rtmp_message_details.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#![plugin(clippy)] #![allow(type_complexity)] extern crate cgmath; #[macro_use] extern crate log; extern crate nanomsg; extern crate num; extern crate rustc_serialize; extern crate stopwatch; extern crate test; extern crate time; pub mod block_position; pub mod closure_series; pub mod color; pub mod com...
code_fim
medium
{ "lang": "rust", "repo": "cgaebel/playform", "path": "/common/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cgaebel/playform path: /common/mod.rs #![deny(missing_docs)] #![deny(warnings)] //! Data structures and functions shared between server and client. #![feature(box_syntax)] #![feature(core)] #![feature(iter_cmp)] #![feature(plugin)] #![feature(test)] #![feature(unboxed_closures)] <|fim_suffix|...
code_fim
hard
{ "lang": "rust", "repo": "cgaebel/playform", "path": "/common/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}({}) took {} ms", label, scramble, elapsed.as_secs() * 1000 + ((elapsed.subsec_nanos() / 1000000) as u64)) }<|fim_prefix|>// repo: unixpickle/locky-puzzle path: /src/bench/bench_solve.rs //! Time how long it takes to solve certain scrambles on the puzzle. extern crate locky_puzzl...
code_fim
hard
{ "lang": "rust", "repo": "unixpickle/locky-puzzle", "path": "/src/bench/bench_solve.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: unixpickle/locky-puzzle path: /src/bench/bench_solve.rs //! Time how long it takes to solve certain scrambles on the puzzle. extern crate locky_puzzle; use std::time::Instant; use locky_puzzle::{Algo, Heuristic, NopHeuristic, solve}; fn main() { time_solve("NopHeuristic", "B D2 B' U2 L2",...
code_fim
medium
{ "lang": "rust", "repo": "unixpickle/locky-puzzle", "path": "/src/bench/bench_solve.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yokljo/prefab path: /legion-transaction/src/lib.rs // Implements a safer, easier to use layer on top of legion's clone_from and clone_from_single by // using the type registry in legion-prefab mod clone_merge; pub use clone_merge::CopyCloneImpl; pub use clone_merge::SpawnCloneImpl; pub use clone...
code_fim
hard
{ "lang": "rust", "repo": "yokljo/prefab", "path": "/legion-transaction/src/lib.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>// Generates diffs by comparing legion worlds mod transactions; pub use transactions::TransactionBuilder; pub use transactions::Transaction; pub use transactions::TransactionDiffs; pub use transactions::TransactionEntityInfo; // A utility iterator that simplifies accessing values from SpawnFrom mod optio...
code_fim
hard
{ "lang": "rust", "repo": "yokljo/prefab", "path": "/legion-transaction/src/lib.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Type-3/rAdmin path: /src/cli/mod.rs mod db; pub use self::db::Database; <|fim_suffix|>mod storage; pub use self::storage::Storage; mod table; pub use self::table::Table;<|fim_middle|>mod app; pub use self::app::CliApp;
code_fim
easy
{ "lang": "rust", "repo": "Type-3/rAdmin", "path": "/src/cli/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Type-3/rAdmin path: /src/cli/mod.rs mod db; pub use self::db::Database; mod app; pub use self::app::CliApp; <|fim_suffix|>mod table; pub use self::table::Table;<|fim_middle|>mod storage; pub use self::storage::Storage;
code_fim
easy
{ "lang": "rust", "repo": "Type-3/rAdmin", "path": "/src/cli/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod table; pub use self::table::Table;<|fim_prefix|>// repo: Type-3/rAdmin path: /src/cli/mod.rs mod db; pub use self::db::Database; <|fim_middle|>mod app; pub use self::app::CliApp; mod storage; pub use self::storage::Storage;
code_fim
medium
{ "lang": "rust", "repo": "Type-3/rAdmin", "path": "/src/cli/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChingChuan-Chen/emu path: /emu_core/src/compile_impls.rs t self, code: impl Into<String>) -> Self { self.code = code.into(); self } } /// A `shaderc`-based compiler for [`Glsl`](struct.Glsl.html) to SPIR-V #[cfg(feature = "glsl-compile")] pub struct GlslCompile; #[cfg(featu...
code_fim
hard
{ "lang": "rust", "repo": "ChingChuan-Chen/emu", "path": "/emu_core/src/compile_impls.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Declares an additional parameter - that is constant - to the compute kernel in this GLSL pub fn add_param<T: ?Sized>(mut self) -> Self { self.params_builder = self.params_builder.param::<T>(Mutability::Const); self } /// Declares an additional parameter - that is mutab...
code_fim
hard
{ "lang": "rust", "repo": "ChingChuan-Chen/emu", "path": "/emu_core/src/compile_impls.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChingChuan-Chen/emu path: /emu_core/src/compile_impls.rs at[] data; /// }; /// /// // if you are passing in multiple arguments of primitive types, /// // you may want to store each argument in a field of a structure and /// // then pass that structure into a buffer in a GLSL kernel /// layout(se...
code_fim
hard
{ "lang": "rust", "repo": "ChingChuan-Chen/emu", "path": "/emu_core/src/compile_impls.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jimblandy/rbattle path: /src/state.rs completes an interaction with an interface element, //! only then is the `State` affected. use graph::{Node, Graph}; use map::{Map, MapParameters}; use xorshift::XorShift128Plus; use rand::Rng; use std::collections::hash_map::DefaultHasher; use std::has...
code_fim
hard
{ "lang": "rust", "repo": "jimblandy/rbattle", "path": "/src/state.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_no_flow_from_empty_cell() { // Florin, alas, has ambitions of conquest but no goop to carry them out with. let mut florin = Some(Occupied { player: Player(1), outflows: vec![2, 3, 4], goop: 0 }); // Florin can try to flow into a cell that's never been occupied, but since /...
code_fim
hard
{ "lang": "rust", "repo": "jimblandy/rbattle", "path": "/src/state.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_attack_empty_cell() { // Florin siezes the opportunity to invade Guilder, which is left unguarded. let mut florin = Some(Occupied { player: Player(1), outflows: vec![2], goop: 3 }); let mut guilder = Some(Occupied { player: Player(2), outflows: vec![1], goop: 0 }); // Thi...
code_fim
hard
{ "lang": "rust", "repo": "jimblandy/rbattle", "path": "/src/state.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl GameOverState { /// Creates a new GameOverState with default values pub fn new(ctx: &mut Context) -> GameOverState { let font = graphics::Font::new(ctx, "/square.ttf").unwrap(); let t = graphics::Text::new(("GAME OVER!\nPress Enter To Go Back To The Main Menu".to_string(), fon...
code_fim
hard
{ "lang": "rust", "repo": "DukeKamono/macguffin_quest", "path": "/src/states/game_over_state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DukeKamono/macguffin_quest path: /src/states/game_over_state.rs /// Game over menu state for game. /// Sadly informs the player they have lost and lets them return to the main game state. pub struct GameOverState { text: graphics::Text, } /// Implement CustomEventHandler from macguffin_ques...
code_fim
hard
{ "lang": "rust", "repo": "DukeKamono/macguffin_quest", "path": "/src/states/game_over_state.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (tx, rx) = mpsc::channel(); thread::spawn(move || { for c in stdin().keys() { tx.send(c.unwrap()).unwrap(); } }); let mut stdout = stdout().into_raw_mode().unwrap(); write!(stdout, "{}{}", clear::All, cursor::Hide)?; let size = terminal_size().map_...
code_fim
medium
{ "lang": "rust", "repo": "rsalmei/ballbounce", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rsalmei/ballbounce path: /src/main.rs #[macro_use] mod colors; mod ball; mod board; mod domain; mod game; use domain::Size; use game::Game; use std::io::{self, stdin, stdout, Write}; use std::sync::mpsc::{self}; use std::thread; use termion::cursor; use termion::input::TermRead; use termion::ra...
code_fim
medium
{ "lang": "rust", "repo": "rsalmei/ballbounce", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mqnfred/ffishim path: /ffishim/src/types/option.rs use ::syn::*; use crate::helpers::*; /// The std lib's `Option` type behavior. pub struct Behavior; impl super::Behavior for Behavior { fn is(&self, sty: &Type) -> bool { if let Type::Path(tp) = sty { is_same_id(&tp.pat...
code_fim
hard
{ "lang": "rust", "repo": "mqnfred/ffishim", "path": "/ffishim/src/types/option.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let subtype = sty.clone().into_subtype(); let receiver: Expr = parse_quote! { tmp }; let subexpr = crate::types::switch(&subtype).try_into(&subtype, receiver.clone()); parse_quote! { { let tmp: Result<#sty, ::ffishim::library::Error>; ...
code_fim
hard
{ "lang": "rust", "repo": "mqnfred/ffishim", "path": "/ffishim/src/types/option.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn run(&mut self, cpu: &mut DCPU, cycles: usize) -> () { match self.cycles_between_ticks { Some(n_cycles) => { self.cycles_in_current_tick += cycles; while self.cycles_in_current_tick >= n_cycles { self.cycles_in_current_tick -= n...
code_fim
hard
{ "lang": "rust", "repo": "LordAro/dcpu16", "path": "/src/devices/clock_generic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> 1 } fn process_interrupt(&mut self, cpu: &mut DCPU) -> () { let reg_a = cpu.reg[dcpu::REG_A]; let reg_b = cpu.reg[dcpu::REG_B]; match reg_a { 0 => { // Set clock tick if reg_b == 0 { self.cycles_betwee...
code_fim
hard
{ "lang": "rust", "repo": "LordAro/dcpu16", "path": "/src/devices/clock_generic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LordAro/dcpu16 path: /src/devices/clock_generic.rs use dcpu::{self, DCPU, Device}; use std::any::Any; // Currently, the clock is based on DCPU-16 cycles, so it could be implemented with software on the // DCPU-16 itself. pub struct DeviceClockGeneric { //over_sixty_per_seconds: u16, cy...
code_fim
hard
{ "lang": "rust", "repo": "LordAro/dcpu16", "path": "/src/devices/clock_generic.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(pool.add_entry(entry1, Status::Pending).unwrap()); assert!(pool.add_entry(entry2, Status::Pending).unwrap()); assert!(pool.add_entry(entry3, Status::Pending).unwrap()); let e1 = pool.next_evict_entry(Status::Pending).unwrap(); assert_eq!(e1, tx1.proposal_short_id()); pool....
code_fim
hard
{ "lang": "rust", "repo": "nervosnetwork/ckb", "path": "/tx-pool/src/component/tests/pending.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nervosnetwork/ckb path: /tx-pool/src/component/tests/pending.rs use crate::component::edges::Edges; use crate::component::tests::util::{ build_tx, build_tx_with_dep, build_tx_with_header_dep, MOCK_CYCLES, MOCK_FEE, MOCK_SIZE, }; use crate::component::{ entry::TxEntry, pool_map::{Pool...
code_fim
hard
{ "lang": "rust", "repo": "nervosnetwork/ckb", "path": "/tx-pool/src/component/tests/pending.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nervosnetwork/ckb path: /tx-pool/src/component/tests/pending.rs te::component::edges::Edges; use crate::component::tests::util::{ build_tx, build_tx_with_dep, build_tx_with_header_dep, MOCK_CYCLES, MOCK_FEE, MOCK_SIZE, }; use crate::component::{ entry::TxEntry, pool_map::{PoolMap, St...
code_fim
hard
{ "lang": "rust", "repo": "nervosnetwork/ckb", "path": "/tx-pool/src/component/tests/pending.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> mut inpt: Tendril<form::Bytes, A>, decoder: &mut enc::Decoder, sink: &mut Sink, last: bool) where Sink: TendrilSink<form::UTF8, A>, A: Atomicity { loop { let mut outt = <Tendril<form::Bytes, A>>::new(); let len = decoder .max_utf8_buffer_length(inpt.len(...
code_fim
hard
{ "lang": "rust", "repo": "dekellum/marked", "path": "/marked/src/decode.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dekellum/marked path: /marked/src/decode.rs // Copyright © 2019 David Kellum // // The `Decoder` implemented here was originally derived from // `tendril::stream::LossyDecoder` and `tendril::stream::TendrilSink` // (version 0.4.1) source as found: // // https://github.com/servo/tendril // Copyri...
code_fim
hard
{ "lang": "rust", "repo": "dekellum/marked", "path": "/marked/src/decode.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Librechain/brb_membership path: /src/actor/ed25519.rs use ed25519::{Digest, Keypair, PublicKey, Sha512, Signature, Signer, Verifier}; use serde::{Deserialize, Serialize}; use rand::rngs::OsRng; use std::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd}; use std::convert::TryInto; use std::fmt; us...
code_fim
hard
{ "lang": "rust", "repo": "Librechain/brb_membership", "path": "/src/actor/ed25519.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Actor(self.0.public) } } impl fmt::Display for SigningActor { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let bytes = self.0.to_bytes(); write!(f, "SA:{}", hex::encode(&bytes[..3])) } } impl fmt::Debug for SigningActor { fn fmt(&self, f: &mut fmt::F...
code_fim
hard
{ "lang": "rust", "repo": "Librechain/brb_membership", "path": "/src/actor/ed25519.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shantanoo-desai/grpc-rust-tonic path: /build.rs fn main() -> Result<(), Box<dyn std::error::Error>> { <|fim_suffix|> // Chapter 3: gRPC Communication Patterns let chap3_iface_files = &["api/v2/protos/order_mgmt.proto"]; tonic_build::configure() .compile(chap3_iface_files, dir...
code_fim
hard
{ "lang": "rust", "repo": "shantanoo-desai/grpc-rust-tonic", "path": "/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Chapter 3: gRPC Communication Patterns let chap3_iface_files = &["api/v2/protos/order_mgmt.proto"]; tonic_build::configure() .compile(chap3_iface_files, dirs) .unwrap(); Ok(()) }<|fim_prefix|>// repo: shantanoo-desai/grpc-rust-tonic path: /build.rs fn main() -> Result<(...
code_fim
medium
{ "lang": "rust", "repo": "shantanoo-desai/grpc-rust-tonic", "path": "/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> u8 as * const c_char , types : unsafe { & types_null as * const _ } , } , ] ; pub static mut zwlr_input_inhibitor_v1_interface : wl_interface = wl_interface { name : b"zwlr_input_inhibitor_v1\0" as * const u8 as * const c_char , version : 1 , request_count : 1 , requests : unsafe { & zwlr_input_inhibitor...
code_fim
hard
{ "lang": "rust", "repo": "pappgeri096/rust_snake", "path": "/game/target/debug/build/wayland-protocols-2efe24f781889194/out/wlr-input-inhibitor-v1_c_interfaces.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn it_adds_two() { assert_eq!(4, add_two(2)); } #[test] #[should_panic(expected = "Didnt expect a value under 1 or over 100! Actual value")] fn guess_greater_than_100() { Guess::new(101); } }<|fim_prefix|>// repo: corka149/guessing_game path: /examples...
code_fim
hard
{ "lang": "rust", "repo": "corka149/guessing_game", "path": "/examples/adder/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let smaller = Rectangle { x: 10, y: 10 }; let larger = Rectangle { x: 5, y: 5 }; assert!(!larger.can_hold(&smaller)); } #[test] fn it_adds_two() { assert_eq!(4, add_two(2)); } #[test] #[should_panic(expected = "Didnt expect a value under 1 or over...
code_fim
medium
{ "lang": "rust", "repo": "corka149/guessing_game", "path": "/examples/adder/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: corka149/guessing_game path: /examples/adder/src/lib.rs #[derive(Debug)] pub struct Rectangle { x: i32, y: i32, } impl Rectangle { pub fn can_hold(&self, other: &Rectangle) -> bool { self.x > other.x && self.y > other.y } } pub fn add_two(target: i32) -> i32 { targe...
code_fim
hard
{ "lang": "rust", "repo": "corka149/guessing_game", "path": "/examples/adder/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sat0-hir0/contentful-rs path: /src/http_client.rs use reqwest; use reqwest::StatusCode; use serde::de::DeserializeOwned; use serde_json::Value; pub(crate) async fn get<T>( url: &String, bearer_token: &String, ) -> Result<Option<T>, Box<dyn std::error::Error>> where T: DeserializeOwn...
code_fim
hard
{ "lang": "rust", "repo": "sat0-hir0/contentful-rs", "path": "/src/http_client.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match resp.status() { StatusCode::OK | StatusCode::CREATED => { let json = resp.json::<Value>().await?; Ok(json) } _ => { log::warn!("{:?}", &resp); log::warn!("{:?}", &resp.text().await?); todo!("handle response statu...
code_fim
hard
{ "lang": "rust", "repo": "sat0-hir0/contentful-rs", "path": "/src/http_client.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let resp = builder.send().await?; match resp.status() { StatusCode::OK | StatusCode::CREATED => { let json = resp.json::<Value>().await?; Ok(json) } _ => { log::warn!("{:?}", &resp); log::warn!("{:?}", &resp.text().await?); ...
code_fim
hard
{ "lang": "rust", "repo": "sat0-hir0/contentful-rs", "path": "/src/http_client.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FreeCX/advent-of-code path: /2022/day01/src/part_two.rs struct Top3 { a: u32, b: u32, c: u32, } impl Top3 { fn new() -> Top3 { Top3 { a: 0, b: 0, c: 0 } } <|fim_suffix|> self.a + self.b + self.c } } pub fn process(input: &str) -> u32 { let mut items ...
code_fim
hard
{ "lang": "rust", "repo": "FreeCX/advent-of-code", "path": "/2022/day01/src/part_two.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> self.a + self.b + self.c } } pub fn process(input: &str) -> u32 { let mut items = Top3::new(); let mut cur_value = 0; for item in input.split('\n') { if item.is_empty() { items.push(cur_value); cur_value = 0; continue; } ...
code_fim
medium
{ "lang": "rust", "repo": "FreeCX/advent-of-code", "path": "/2022/day01/src/part_two.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MinusGix/Vivec path: /src/records/avif.rs use super::{ common::{ get_field, CollectionList, CommonRecordInfo, ConversionError, FromRecord, FromRecordError, GeneralRecord, NullTerminatedString, StaticTypeNamed, TypeNamed, }, fields::{ common::{ item...
code_fim
hard
{ "lang": "rust", "repo": "MinusGix/Vivec", "path": "/src/records/avif.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> where T: Write, { write_field_header(self, w)?; match self { CNAM::SkillCategory(skill) => skill.write_to(w), CNAM::Unknown(x) => x.write_to(w), } } } #[derive(Debug, Copy, Clone, PartialEq)] pub struct AVSK { pub skill_use_multiplie...
code_fim
hard
{ "lang": "rust", "repo": "MinusGix/Vivec", "path": "/src/records/avif.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fossabot/necsim-rust path: /necsim/core/src/cogs/emigration_exit.rs use necsim_core_bond::{NonNegativeF64, PositiveF64}; use crate::{ cogs::{Habitat, LineageReference, LineageStore, RngCore}, landscape::{IndexedLocation, Location}, simulation::partial::emigration_exit::PartialSimula...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/necsim-rust", "path": "/necsim/core/src/cogs/emigration_exit.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, lineage_reference: R, dispersal_origin: IndexedLocation, dispersal_target: Location, prior_time: NonNegativeF64, event_time: PositiveF64, simulation: &mut PartialSimulation<H, G, R, S>, rng: &mut G, ) -> Option<(R, IndexedLocat...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/necsim-rust", "path": "/necsim/core/src/cogs/emigration_exit.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bshankar/qss path: /src/board.rs macro_rules! link { ($self: ident, $name: ident, $dir: ident, $opp_dir: ident) => { fn $name(&mut $self, a: u16, b: u16) { $self.$dir[a as usize] = b; $self.$opp_dir[b as usize] = a; } } } macro_rules! remove { ...
code_fim
hard
{ "lang": "rust", "repo": "bshankar/qss", "path": "/src/board.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Board { up: [u16; 3241], down: [u16; 3241], left: [u16; 3241], right: [u16; 3241], column: [u16; 2916], sizes: [u8; 324], solution: [u16; 729], solved: bool, root: u16, } impl Board { pub fn new() -> Self { let mut board = Board { up:...
code_fim
hard
{ "lang": "rust", "repo": "bshankar/qss", "path": "/src/board.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for c in 0..81 { for d in 0..9 { let v: u16 = 4 * (9 * c + d) + 325; for i in 0..4 { let cs = self.columns(c, d); self.link_down(boc[cs[i] as usize], v + i as u16); self.column[v as usize + i - ...
code_fim
hard
{ "lang": "rust", "repo": "bshankar/qss", "path": "/src/board.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let poly: LineString<f64> = line_string![(x: 3.3, y: 30.4), (x: 1.7, y: 24.6), (x: 13.4, y: 25.1), (x: 14.4, y: 31.0)]; let mbr = MinimumRotatedRect::minimum_rotated_rect(&poly).unwrap(); assert_eq!( mbr.exterior(), &LineString::from(vec![ (1...
code_fim
hard
{ "lang": "rust", "repo": "georust/geo", "path": "/geo/src/algorithm/minimum_rotated_rect.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let poly: Polygon<f64> = polygon![(x: 3.3, y: 30.4), (x: 1.7, y: 24.6), (x: 13.4, y: 25.1), (x: 14.4, y: 31.0),(x:3.3,y:30.4)]; let mbr = MinimumRotatedRect::minimum_rotated_rect(&poly).unwrap(); assert_eq!( mbr.exterior(), &LineString::from(vec![ ...
code_fim
hard
{ "lang": "rust", "repo": "georust/geo", "path": "/geo/src/algorithm/minimum_rotated_rect.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }