text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: apoelstra/rust-serde path: /src/json/error.rs use std::error; use std::fmt; use std::io; use de; /// The errors that can arise while parsing a JSON stream. #[derive(Copy, Clone, PartialEq)] pub enum ErrorCode { EOFWhileParsingList, EOFWhileParsingObject, EOFWhileParsingString, ...
code_fim
hard
{ "lang": "rust", "repo": "apoelstra/rust-serde", "path": "/src/json/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match error { de::value::Error::SyntaxError => { de::Error::syntax_error() } de::value::Error::EndOfStreamError => { de::Error::end_of_stream_error() } de::value::Error::MissingFieldError(field) => { ...
code_fim
hard
{ "lang": "rust", "repo": "apoelstra/rust-serde", "path": "/src/json/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Error::IoError(error) } } impl From<de::value::Error> for Error { fn from(error: de::value::Error) -> Error { match error { de::value::Error::SyntaxError => { de::Error::syntax_error() } de::value::Error::EndOfStreamError => { ...
code_fim
hard
{ "lang": "rust", "repo": "apoelstra/rust-serde", "path": "/src/json/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mod smart_pointer; mod sync_test; mod async_test; pub fn test() { guess_num_game::test(); }<|fim_prefix|>// repo: krilie/rust-hello path: /base/orihello/src/test_al/mod.rs mod linear_search; mod learn_helloworld; mod gu<|fim_middle|>ess_num_game; mod struct_data; mod traits_test;
code_fim
easy
{ "lang": "rust", "repo": "krilie/rust-hello", "path": "/base/orihello/src/test_al/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>; pub fn test() { guess_num_game::test(); }<|fim_prefix|>// repo: krilie/rust-hello path: /base/orihello/src/test_al/mod.rs mod linear_search; mod learn_helloworld; mod guess_num_game; mod struct_data; mod traits_test; <|fim_middle|>mod smart_pointer; mod sync_test; mod async_test
code_fim
easy
{ "lang": "rust", "repo": "krilie/rust-hello", "path": "/base/orihello/src/test_al/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: krilie/rust-hello path: /base/orihello/src/test_al/mod.rs mod linear_search; mod learn_helloworld; mod gu<|fim_suffix|>mod smart_pointer; mod sync_test; mod async_test; pub fn test() { guess_num_game::test(); }<|fim_middle|>ess_num_game; mod struct_data; mod traits_test;
code_fim
easy
{ "lang": "rust", "repo": "krilie/rust-hello", "path": "/base/orihello/src/test_al/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let x = 12; let x = x; }<|fim_prefix|>// repo: fisherdarling/cargo-light path: /example.rs fn some_function() { let name = 12; let name = 15f32; let name = name; <|fim_middle|> let var1 = 12; let var1 = 15f32; let var1 = var1; let x = 12; let x = x; } fn another_...
code_fim
medium
{ "lang": "rust", "repo": "fisherdarling/cargo-light", "path": "/example.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let y = 12; let y = y; let i = 12; let i = 15f32; let i = i; let x = 12; let x = x; }<|fim_prefix|>// repo: fisherdarling/cargo-light path: /example.rs fn some_function() { let name = 12; let name = 15f32; let name = name; let var1 = 12; let var1 = 15f32...
code_fim
easy
{ "lang": "rust", "repo": "fisherdarling/cargo-light", "path": "/example.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fisherdarling/cargo-light path: /example.rs fn some_function() { let name = 12; let name = 15f32; let name = name; <|fim_suffix|> let y = 12; let y = y; let i = 12; let i = 15f32; let i = i; let x = 12; let x = x; }<|fim_middle|> let var1 = 12; le...
code_fim
medium
{ "lang": "rust", "repo": "fisherdarling/cargo-light", "path": "/example.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vorujack/age-usd path: /ageusd-cli/src/main.rs adless::update::{BallotBox, UpdateBox}; use ergo_headless_dapp_framework::{nano_erg_to_erg, NanoErg, P2PKAddressString, P2SAddressString}; pub type Result<T> = std::result::Result<T, anyhow::Error>; const USAGE: &'static str = r#" Usage: s...
code_fim
hard
{ "lang": "rust", "repo": "vorujack/age-usd", "path": "/ageusd-cli/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vorujack/age-usd path: /ageusd-cli/src/main.rs ).unwrap(); // Create the Bank Box let bank_box = BankBox::new(&scans.bank_scan.get_box().unwrap()).unwrap(); println!("Circulating Status\n==================="); println!( "Amount Of Circulating AgeUSD: ...
code_fim
hard
{ "lang": "rust", "repo": "vorujack/age-usd", "path": "/ageusd-cli/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Update Protocol fn update_protocol( update_address: &P2SAddressString, user_address: &P2PKAddressString, node: &NodeInterface, ) -> String { // Acquiring Scans let scans = get_protocol_scans(&node); // Acquire protocol let protocol = StableCoinProtocol::new(); // Creat...
code_fim
hard
{ "lang": "rust", "repo": "vorujack/age-usd", "path": "/ageusd-cli/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andrewrk/glium path: /src/context/extensions.rs use std::ffi; use gl; /// Contains data about the list of extensions #[derive(Debug, Clone, Copy)] pub struct ExtensionsList { /// GL_EXT_direct_state_access pub gl_ext_direct_state_access: bool, /// GL_EXT_framebuffer_object pub g...
code_fim
hard
{ "lang": "rust", "repo": "andrewrk/glium", "path": "/src/context/extensions.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> extensions } fn get_extensions_strings(gl: &gl::Gl) -> Vec<String> { unsafe { let list = gl.GetString(gl::EXTENSIONS); if list.is_null() { let mut num_extensions = 0; gl.GetIntegerv(gl::NUM_EXTENSIONS, &mut num_extensions); range(0, num_extens...
code_fim
hard
{ "lang": "rust", "repo": "andrewrk/glium", "path": "/src/context/extensions.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!("Starting event loop"); // Runs the event pool until the consumer terminates. core.run(processed_stream).unwrap(); println!("Stream processing terminated"); } fn main() { let matches = App::new("Kafka Consumer") .version(option_env!("CARGO_PKG_VERSION").unwrap_or(""))...
code_fim
hard
{ "lang": "rust", "repo": "kanekv/grpctest", "path": "/src/bin/consumer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kanekv/grpctest path: /src/bin/consumer.rs #[macro_use] extern crate log; extern crate clap; extern crate rdkafka; extern crate tokio_core; extern crate futures; mod utils; use rdkafka::consumer::{Consumer, ConsumerContext}; use futures::stream::Stream; use clap::{App, Arg}; use tokio_core::r...
code_fim
hard
{ "lang": "rust", "repo": "kanekv/grpctest", "path": "/src/bin/consumer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> consumer.subscribe(&[topic]).expect("Can't subscribe to specified topic"); // Create the outer pipeline on the message stream. let processed_stream = consumer.start() .filter_map(|result| { // Filter out errors match result { Ok(msg) => Some(msg...
code_fim
hard
{ "lang": "rust", "repo": "kanekv/grpctest", "path": "/src/bin/consumer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WSeegers/filler_mk2 path: /src/models/player.rs use super::constants::*; use serde::Serialize; use std::fmt::{Display, Formatter, Result}; #[derive(Debug, Copy, Clone, Serialize)] pub enum Player { Player1, Player2, } <|fim_suffix|> use Player::{Player1, Player2}; let c ...
code_fim
medium
{ "lang": "rust", "repo": "WSeegers/filler_mk2", "path": "/src/models/player.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Display for Player { fn fmt(&self, f: &mut Formatter) -> Result { use Player::{Player1, Player2}; let c = match self { Player1 => PLAYER1, Player2 => PLAYER2, }; write!(f, "{}", c) } }<|fim_prefix|>// repo: WSeegers/filler_mk2 path: /sr...
code_fim
medium
{ "lang": "rust", "repo": "WSeegers/filler_mk2", "path": "/src/models/player.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use Player::{Player1, Player2}; let c = match self { Player1 => PLAYER1, Player2 => PLAYER2, }; write!(f, "{}", c) } }<|fim_prefix|>// repo: WSeegers/filler_mk2 path: /src/models/player.rs use super::constants::*; use serde::Serialize; use std::...
code_fim
medium
{ "lang": "rust", "repo": "WSeegers/filler_mk2", "path": "/src/models/player.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: callym/pbrst path: /pbrt/src/integrator/mod.rs use crate::scene::Scene; use crate::sampler::Sampler; <|fim_suffix|> fn preprocess(&mut self, _scene: &Scene, _sampler: &mut dyn Sampler) { } }<|fim_middle|>mod sampler_integrator; pub use self::sampler_integrator::{ ParIntegratorData, Sam...
code_fim
hard
{ "lang": "rust", "repo": "callym/pbrst", "path": "/pbrt/src/integrator/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod normal; pub use self::normal::{ NormalIntegrator }; mod direct_lighting; pub use self::direct_lighting::{ DirectLightingIntegrator, LightStrategy }; mod whitted; pub use self::whitted::WhittedIntegrator; pub mod utils; pub trait Integrator { fn render(&mut self, scene: Scene); fn preproce...
code_fim
medium
{ "lang": "rust", "repo": "callym/pbrst", "path": "/pbrt/src/integrator/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn preprocess(&mut self, _scene: &Scene, _sampler: &mut dyn Sampler) { } }<|fim_prefix|>// repo: callym/pbrst path: /pbrt/src/integrator/mod.rs use crate::scene::Scene; use crate::sampler::Sampler; mod sampler_integrator; pub use self::sampler_integrator::{ ParIntegratorData, SamplerIntegrator ...
code_fim
hard
{ "lang": "rust", "repo": "callym/pbrst", "path": "/pbrt/src/integrator/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> IterMut { next: self.head.as_mut().map(|node| &mut **node), } } } impl<'a, T> Iterator for IterMut<'a, T> { type Item = &'a mut T; fn next(&mut self) -> Option<Self::Item> { let x = self.next.take(); let y = x.map(|node| { // let a = nod...
code_fim
hard
{ "lang": "rust", "repo": "santoshkc/rust_adventure", "path": "/src/efficientlist.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: santoshkc/rust_adventure path: /src/efficientlist.rs type Link<T> = Option<Box<Node<T>>>; struct Node<T> { element: T, next: Link<T>, } pub struct EfficientList<T> { head: Link<T>, } impl<T> Drop for EfficientList<T> { fn drop(&mut self) { let mut cur_link = self.head.t...
code_fim
hard
{ "lang": "rust", "repo": "santoshkc/rust_adventure", "path": "/src/efficientlist.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Funky directory structure to test that relative tool paths are made absolute // by reference to the `.cargo/..` directory and not to (for example) the CWD. let origin = project("origin") .file("foo/Cargo.toml", r#" [package] name = "foo" version =...
code_fim
hard
{ "lang": "rust", "repo": "tapeinosyne/cargo", "path": "/tests/tool-paths.rs", "mode": "spm", "license": "GCC-exception-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tapeinosyne/cargo path: /tests/tool-paths.rs extern crate cargotest; extern crate hamcrest; use cargotest::rustc_host; use cargotest::support::{path2url, project, execs}; use hamcrest::assert_that; #[test] fn pathless_tools() { let target = rustc_host(); let foo = project("foo") ...
code_fim
hard
{ "lang": "rust", "repo": "tapeinosyne/cargo", "path": "/tests/tool-paths.rs", "mode": "psm", "license": "GCC-exception-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bjorngronbaek/advent-of-code-2018 path: /aoc/aoc08/src/lib.rs #[cfg(test)] mod tests { #[test] fn test_with_no_sub_nodes() { let v = vec![0,3,1,2,3]; let n = ::sub(&v,0); assert_eq!(n.newsum,6); assert_eq!(n.newindex,5); assert_eq!(n.newv...
code_fim
hard
{ "lang": "rust", "repo": "bjorngronbaek/advent-of-code-2018", "path": "/aoc/aoc08/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut nodevalues = Vec::new(); for node in 0..*subnodes { println!("Processing {} of {} subnodes. Start index is:\t{}",node+1,subnodes,loopindex); let nodevalue = sub(vec,loopindex); loopindex = nodevalue.newindex; loopsum += nodevalue...
code_fim
hard
{ "lang": "rust", "repo": "bjorngronbaek/advent-of-code-2018", "path": "/aoc/aoc08/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self::Lazy(provider) } } #[cfg(feature = "robj")] impl From<robj::lazy_blob::Provider> for Provider { fn from(provider: robj::lazy_blob::Provider) -> Self { Self::LazyBlob(provider) } } impl Provider { /// Releases the provider while keeping the remote object alive //...
code_fim
hard
{ "lang": "rust", "repo": "romatthe/remoc", "path": "/remoc/src/provider.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Self::Handle(provider) } } #[cfg(feature = "robj")] impl From<robj::lazy::Provider> for Provider { fn from(provider: robj::lazy::Provider) -> Self { Self::Lazy(provider) } } #[cfg(feature = "robj")] impl From<robj::lazy_blob::Provider> for Provider { fn from(provider: rob...
code_fim
hard
{ "lang": "rust", "repo": "romatthe/remoc", "path": "/remoc/src/provider.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: romatthe/remoc path: /remoc/src/provider.rs //! Provider for any remote object. #[cfg(feature = "rfn")] use crate::rfn; #[cfg(feature = "robj")] use crate::robj; /// A provider for any remote object. /// /// This helps to store providers of different remote object types together. /// For exam...
code_fim
hard
{ "lang": "rust", "repo": "romatthe/remoc", "path": "/remoc/src/provider.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for case in test_cases.iter() { assert_eq!( case.expected, Solution::is_perfect_square(case.num), ); } } }<|fim_prefix|>// repo: csixteen/LeetCode path: /Problems/Algorithms/src/Rust/valid-perfect-square/src/lib.rs // https://lee...
code_fim
hard
{ "lang": "rust", "repo": "csixteen/LeetCode", "path": "/Problems/Algorithms/src/Rust/valid-perfect-square/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: csixteen/LeetCode path: /Problems/Algorithms/src/Rust/valid-perfect-square/src/lib.rs // https://leetcode.com/problems/valid-perfect-square/ #![allow(dead_code)] use std::cmp::Ordering; struct Solution {} impl Solution { pub fn is_perfect_square(num: i32) -> bool { let num: i64 =...
code_fim
hard
{ "lang": "rust", "repo": "csixteen/LeetCode", "path": "/Problems/Algorithms/src/Rust/valid-perfect-square/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn parse_header(fits: &[u8], last_block: usize, current_block: usize) -> Header { let mut header_records = HashMap::new(); let header_data = &fits[last_block * BLOCK_SIZE..(current_block + 1) * BLOCK_SIZE]; println!("[Found header end]"); for chunk in header_data.chunks(RECORD_SIZE) { ...
code_fim
hard
{ "lang": "rust", "repo": "snarkyboojum/fits-rust", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: snarkyboojum/fits-rust path: /src/main.rs use std::collections::HashMap; use std::env; use std::fs::File; use std::io::Read; use std::path::Path; enum Section { Header, Data, Extension, } struct Fits<'a> { header: Header, data: Data<'a>, extension: Vec<Extension>, } #[...
code_fim
hard
{ "lang": "rust", "repo": "snarkyboojum/fits-rust", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Debug::fmt(&self.inner, f) } } impl_handle_manip!(LocalSocketStream); /// A name for a local socket. /// /// Due to vast differences between platforms in terms of how local sockets are named, there needs to be a way to store and process those in a unified way while also retaining platform-spe...
code_fim
hard
{ "lang": "rust", "repo": "csunday95/interprocess", "path": "/src/local_socket.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// A name for a local socket. /// /// Due to vast differences between platforms in terms of how local sockets are named, there needs to be a way to store and process those in a unified way while also retaining platform-specific pecularities. `LocalSocketName` aims to bridge the gap between portability an...
code_fim
hard
{ "lang": "rust", "repo": "csunday95/interprocess", "path": "/src/local_socket.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: csunday95/interprocess path: /src/local_socket.rs x-like systems, the only way to name a Ud-socket is to use a filesystem path. As such, those platforms don't have the namespaced socket creation method available. Complicatng matters further, Windows does not support named pipes in the normal fil...
code_fim
hard
{ "lang": "rust", "repo": "csunday95/interprocess", "path": "/src/local_socket.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doubleduck98/uni path: /rust/lista1/zad2/src/main.rs fn main() { println!("{}", string_to_number("997")); } fn string_to_number(s: &str) -> i32 { return s.parse().unwrap(); } #[test] fn test0() { assert_eq!(string_to_number("42"), 42); } #[test] fn test1() { assert_eq!(string_t...
code_fim
hard
{ "lang": "rust", "repo": "doubleduck98/uni", "path": "/rust/lista1/zad2/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(string_to_number("997"), 997); } #[test] fn test3() { assert_eq!(string_to_number("-2"), -2); } #[test] fn test4() { assert_eq!(string_to_number("18"), 18); } #[test] fn test5() { assert_eq!(string_to_number("0"), 0); } #[test] fn test6() { assert_eq!(string_to_number("12345...
code_fim
medium
{ "lang": "rust", "repo": "doubleduck98/uni", "path": "/rust/lista1/zad2/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(string_to_number("123456789"), 123456789); } #[test] fn test7() { assert_eq!(string_to_number("2147483647"), 2147483647); } #[test] fn test8() { assert_eq!(string_to_number("-2147483648"), -2147483648); } #[test] fn test9() { assert_eq!(string_to_number("-42"), -42); }<|fim_pref...
code_fim
medium
{ "lang": "rust", "repo": "doubleduck98/uni", "path": "/rust/lista1/zad2/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Some(HitRecord::new(p, Vec3::front(), self.material.clone(), t, u, v)) } fn bounding_box(&self, _time_0: f64, _time_1: f64) -> Option<AABB> { let aabb = AABB::new(Point3::new(self.x0, self.y0, self.z - 0.0001), Point3::new(self.x1, self.y1, self.z + 0.0001)); Some(aabb) ...
code_fim
hard
{ "lang": "rust", "repo": "lams3/raytracing-rust", "path": "/src/hittables/xy_rect.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lams3/raytracing-rust path: /src/hittables/xy_rect.rs use crate::structures::{AABB, HitRecord, Point3, Ray, Vec3}; use crate::hittables::Hittable; use crate::materials::Material; use crate::utility::InverseLerp; use std::sync::Arc; pub struct XYRect { pub material: Arc<dyn Material>, p...
code_fim
medium
{ "lang": "rust", "repo": "lams3/raytracing-rust", "path": "/src/hittables/xy_rect.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn create(&self, device: &wgpu::Device, label: &str) -> wgpu::BindGroup { assert_eq!(self.entries.len(), self.layout_with_desc.entries.len()); let descriptor = wgpu::BindGroupDescriptor { layout: &self.layout_with_desc.layout, entries: &self.entries, ...
code_fim
hard
{ "lang": "rust", "repo": "Wumpf/blub", "path": "/src/wgpu_utils/binding_builder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Wumpf/blub path: /src/wgpu_utils/binding_builder.rs pub struct BindGroupLayoutWithDesc { pub layout: wgpu::BindGroupLayout, pub entries: Vec<wgpu::BindGroupLayoutEntry>, } pub struct BindGroupLayoutBuilder { entries: Vec<wgpu::BindGroupLayoutEntry>, next_binding_index: u32, } i...
code_fim
hard
{ "lang": "rust", "repo": "Wumpf/blub", "path": "/src/wgpu_utils/binding_builder.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Uses same binding index as binding group layout at the same ordering pub fn resource(mut self, resource: wgpu::BindingResource<'a>) -> Self { assert_lt!(self.entries.len(), self.layout_with_desc.entries.len()); self.entries.push(wgpu::BindGroupEntry { binding: self.l...
code_fim
hard
{ "lang": "rust", "repo": "Wumpf/blub", "path": "/src/wgpu_utils/binding_builder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jeremylt/time_complexity path: /benches/benchmark.rs use criterion::{black_box, criterion_group, criterion_main, Criterion}; use time_complexity::{ is_prime, is_prime_all, is_prime_half, is_prime_sqrt, sum_primes, sum_primes_sieve, }; // -----------------------------------------------------...
code_fim
hard
{ "lang": "rust", "repo": "jeremylt/time_complexity", "path": "/benches/benchmark.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub fn sum_primes_half_benchmark(c: &mut Criterion) { let mut group = c.benchmark_group("sum primes - half divisors"); group.bench_function("sum_primes half 1789", |b| { b.iter(|| sum_primes(black_box(SMALL), is_prime_half)) }); group.bench_function("sum_primes half 17903", |b| { ...
code_fim
hard
{ "lang": "rust", "repo": "jeremylt/time_complexity", "path": "/benches/benchmark.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>use cursive::align::HAlign; use cursive::direction::Orientation; use cursive::event::Key; use cursive::view::Identifiable; use cursive::view::View; use cursive::views::{ LinearLayout, OnEventView, ResizedView, SelectView, StackView, TextView, ViewRef, }; use cursive::Cursive; use crate::tui::constants::...
code_fim
hard
{ "lang": "rust", "repo": "mimblewimble/grin", "path": "/src/bin/tui/menu.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mimblewimble/grin path: /src/bin/tui/menu.rs // Copyright 2021 The Grin Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/...
code_fim
hard
{ "lang": "rust", "repo": "mimblewimble/grin", "path": "/src/bin/tui/menu.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bauhaus93/mw-parse path: /esm-parser/src/tuple.rs use parse::Parseable; pub struct Triple<T: Parseable>(pub T, pub T, pub T);<|fim_suffix|> T, pub T, pub T, pub T, pub T, pub T);<|fim_middle|> pub struct Sextuple<T: Parseable>(pub
code_fim
easy
{ "lang": "rust", "repo": "bauhaus93/mw-parse", "path": "/esm-parser/src/tuple.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> T, pub T, pub T, pub T, pub T, pub T);<|fim_prefix|>// repo: bauhaus93/mw-parse path: /esm-parser/src/tuple.rs use parse::Parseable; pub struct Triple<T: Parseable>(pub T, pub T, pub T);<|fim_middle|> pub struct Sextuple<T: Parseable>(pub
code_fim
easy
{ "lang": "rust", "repo": "bauhaus93/mw-parse", "path": "/esm-parser/src/tuple.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bauhaus93/mw-parse path: /esm-parser/src/tuple.rs use parse::Parseable; pub struct Tri<|fim_suffix|> T, pub T, pub T, pub T, pub T, pub T);<|fim_middle|>ple<T: Parseable>(pub T, pub T, pub T); pub struct Sextuple<T: Parseable>(pub
code_fim
medium
{ "lang": "rust", "repo": "bauhaus93/mw-parse", "path": "/esm-parser/src/tuple.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: markov-chain/3d-ice-sys path: /src/dimensions.rs use types::*; #[derive(Clone, Copy)] #[repr(C)] pub struct CellDimensions_t { pub FirstWallLength: CellDimension_t, pub WallLength: CellDimension_t, pub ChannelLength: CellDimension_t, pub LastWallLength: CellDimension_t, pub ...
code_fim
hard
{ "lang": "rust", "repo": "markov-chain/3d-ice-sys", "path": "/src/dimensions.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone, Copy)] #[repr(C)] pub struct Dimensions_t { pub Cell: CellDimensions_t, pub Grid: GridDimensions_t, pub Chip: ChipDimensions_t, } extern "C" { pub fn get_number_of_layers(dimensions: *mut Dimensions_t) -> CellIndex_t; pub fn get_number_of_rows (dimensions: *mut Dimensi...
code_fim
medium
{ "lang": "rust", "repo": "markov-chain/3d-ice-sys", "path": "/src/dimensions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>extern "C" { pub fn get_number_of_layers(dimensions: *mut Dimensions_t) -> CellIndex_t; pub fn get_number_of_rows (dimensions: *mut Dimensions_t) -> CellIndex_t; pub fn get_number_of_columns (dimensions: *mut Dimensions_t) -> CellIndex_t; pub fn get_number_of_cells(dimensions: *mut Dimensi...
code_fim
hard
{ "lang": "rust", "repo": "markov-chain/3d-ice-sys", "path": "/src/dimensions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sapunm/AoC-Solutions path: /2020 - Rust/day-07/src/input.rs yan bags", "wavy beige bags contain 5 dim red bags, 2 dotted crimson bags, 1 muted orange bag", "drab orange bags contain 3 dotted red bags, 1 drab yellow bag, 4 clear tan bags, 1 vibrant chartreuse bag", "mirror...
code_fim
hard
{ "lang": "rust", "repo": "sapunm/AoC-Solutions", "path": "/2020 - Rust/day-07/src/input.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sapunm/AoC-Solutions path: /2020 - Rust/day-07/src/input.rs gs", "striped red bags contain 2 posh bronze bags", "clear teal bags contain 4 vibrant aqua bags, 1 plaid lime bag, 3 bright lime bags, 1 posh beige bag", "mirrored cyan bags contain 5 light green bags", ...
code_fim
hard
{ "lang": "rust", "repo": "sapunm/AoC-Solutions", "path": "/2020 - Rust/day-07/src/input.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> bags, 2 shiny black bags, 1 dim magenta bag, 5 vibrant blue bags", "vibrant lime bags contain 5 drab tan bags, 5 pale beige bags, 1 faded turquoise bag, 4 dull gold bags", "mirrored violet bags contain 1 mirrored bronze bag", "drab crimson bags contain 2 dim indigo bags", ...
code_fim
hard
{ "lang": "rust", "repo": "sapunm/AoC-Solutions", "path": "/2020 - Rust/day-07/src/input.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("methods/associated functions:"); println!("rouding methods:"); eval!(4.2_f64.floor()); eval!((-4.2_f64).floor()); eval!(4.2_f64.ceil()); eval!((-4.2_f64).ceil()); eval!(4.2_f64.round()); eval!((-4.2_f64).round()); eval!(4.2_f64.trunc()); eval!((-4.2_f64).t...
code_fim
hard
{ "lang": "rust", "repo": "logansquirel/rust-programming-language", "path": "/chapter03/floats/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("operators:"); eval!(-1.1); eval!(1.1 + 2.2); eval!(2.2 - 1.1); eval!(1.1 * 2.2); eval!(2.2 / 1.1); eval!(2.3 % 1.1); } #[macro_export] macro_rules! stringify { ($x:expr) => { std::stringify!($x) }; } #[macro_export] macro_rules! eval { ($x:expr) ...
code_fim
hard
{ "lang": "rust", "repo": "logansquirel/rust-programming-language", "path": "/chapter03/floats/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: logansquirel/rust-programming-language path: /chapter03/floats/src/main.rs fn main() { println!("Data type: floats"); println!("{:-<80}", ""); types(); println!("{:-<80}", ""); literals(); println!("{:-<80}", ""); println!("Associated functions/constants/methods/opera...
code_fim
hard
{ "lang": "rust", "repo": "logansquirel/rust-programming-language", "path": "/chapter03/floats/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kinrany/ruma path: /ruma-client-api/src/r0/room/create_room.rs //! [POST /_matrix/client/r0/createRoom](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-createroom) use ruma_api::ruma_api; use ruma_common::Raw; use ruma_events::{ room::{ create::{CreateEventCo...
code_fim
hard
{ "lang": "rust", "repo": "Kinrany/ruma", "path": "/ruma-client-api/src/r0/room/create_room.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Extra options to be added to the `m.room.create` event. /// /// This is the same as the event content struct for `m.room.create`, but without some fields that /// servers are supposed to ignore. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct CreationContent { /// Whether users on other...
code_fim
hard
{ "lang": "rust", "repo": "Kinrany/ruma", "path": "/ruma-client-api/src/r0/room/create_room.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// A list of user IDs to invite to the room. /// /// This will tell the server to invite everyone in the list to the newly created room. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub invite: Vec<UserId>, /// List of third party IDs of users ...
code_fim
hard
{ "lang": "rust", "repo": "Kinrany/ruma", "path": "/ruma-client-api/src/r0/room/create_room.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tirust/msp432e4 path: /src/usb0/rxcsrl7.rs er"] #[inline(always)] pub const fn reset_value() -> u8 { 0 } #[doc = r"Writes the reset value to the register"] #[inline(always)] pub fn reset(&self) { self.register.set(Self::reset_value()) } } #[doc = r"Val...
code_fim
hard
{ "lang": "rust", "repo": "tirust/msp432e4", "path": "/src/usb0/rxcsrl7.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits &= !(1 << 5); self.w.bits |= ((value as u8) & 1) << 5; self.w ...
code_fim
hard
{ "lang": "rust", "repo": "tirust/msp432e4", "path": "/src/usb0/rxcsrl7.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>- Receive Packet Ready"] #[inline(always)] pub fn usb_rxcsrl7_rxrdy(&self) -> USB_RXCSRL7_RXRDYR { let bits = ((self.bits >> 0) & 1) != 0; USB_RXCSRL7_RXRDYR { bits } } #[doc = "Bit 1 - FIFO Full"] #[inline(always)] pub fn usb_rxcsrl7_full(&self) -> USB_RXCSRL7_FULL...
code_fim
hard
{ "lang": "rust", "repo": "tirust/msp432e4", "path": "/src/usb0/rxcsrl7.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BartMassey/global-rng path: /src/main.rs use rand::*; use rand::rngs::SmallRng; use ugly_global::*; global_vars! { RNG: R; } struct R { gen: Box<dyn RngCore + Send + Sync>, } impl R { fn new() -> R { R { gen: Box::new(SmallRng::from_entropy()) } } } struct BadR { ...
code_fim
hard
{ "lang": "rust", "repo": "BartMassey/global-rng", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl RngCore for BadR { fn next_u32(&mut self) -> u32 { let r = self.next_u32(); // println!("→u32 {}", r); r } fn next_u64(&mut self) -> u64 { let r1 = self.next_u32() as u64; let r2 = self.next_u32() as u64; // println!("→u64 {} {}", r1, r2); ...
code_fim
hard
{ "lang": "rust", "repo": "BartMassey/global-rng", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32h5/src/stm32h503/comp.rs #[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Comparator status register"] pub comp_sr: COMP_SR, #[doc = "0x04 - Comparator interrupt clear flag register"] pub comp_icfr: COMP_ICFR...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h5/src/stm32h503/comp.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>SPEC>; #[doc = "Comparator interrupt clear flag register"] pub mod comp_icfr; #[doc = "COMP_CFGR1 (rw) register accessor: Comparator configuration register 1\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`comp_cfgr1::R`]. You can [`reset`](crate::generic::Reg::reset), [`write`](cr...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h5/src/stm32h503/comp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ration register 1"] pub mod comp_cfgr1; #[doc = "COMP_CFGR2 (rw) register accessor: Comparator configuration register 2\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`comp_cfgr2::R`]. You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_wit...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h5/src/stm32h503/comp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> run_test_kernel(env!("CARGO_BIN_FILE_TEST_KERNEL_MIN_STACK_basic_boot")); }<|fim_prefix|>// repo: rust-osdev/bootloader path: /tests/min_stack.rs use bootloader_test_runner::run_test_kernel; <|fim_middle|>#[test] fn basic_boot() {
code_fim
easy
{ "lang": "rust", "repo": "rust-osdev/bootloader", "path": "/tests/min_stack.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-osdev/bootloader path: /tests/min_stack.rs use bootloader_test_runner::run_test_kernel; <|fim_suffix|> run_test_kernel(env!("CARGO_BIN_FILE_TEST_KERNEL_MIN_STACK_basic_boot")); }<|fim_middle|>#[test] fn basic_boot() {
code_fim
easy
{ "lang": "rust", "repo": "rust-osdev/bootloader", "path": "/tests/min_stack.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nixpulvis/hell path: /3/take5/take5-cli/src/main.rs //! Running a game of take5 from the command line. //! //! # Usage //! //! ```sh //! The card game take5 (or 6nimmit!). //! //! Usage: //! take5 <players> //! take5 [--conf=<file>, --bulls=<file>, --human] <players> //! take5 [-hv] ...
code_fim
hard
{ "lang": "rust", "repo": "nixpulvis/hell", "path": "/3/take5/take5-cli/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn players(args: &Args) -> Vec<Box<Player>> { (0..args.arg_players).map(|id| { if args.flag_human { Box::new(StdinPlayer::new(id)) as Box<Player> } else { Box::new(AiPlayer::new(id)) as Box<Player> } }).collect() ...
code_fim
hard
{ "lang": "rust", "repo": "nixpulvis/hell", "path": "/3/take5/take5-cli/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut game = state::new(init::dealer(&args), init::players(&args)); game.run(); game.report(); } #[cfg(feature = "ext")] mod init { use args::Args; use take5::player::{Player, AiPlayer}; use take5::dealer::{Dealer, StandardDealer}; use take5_ext::{CustomDealer, StdinPlayer};...
code_fim
hard
{ "lang": "rust", "repo": "nixpulvis/hell", "path": "/3/take5/take5-cli/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] fn nth_back(&mut self, n: usize) -> Option<Self::Item> { if n < self.count { let out = Some(unsafe { self.base.cast::<[u8; S]>().add(self.count - (n + 1)).cast::<T>() }); self.count -= n + 1; out } else { self.count = 0; None } } } #...
code_fim
hard
{ "lang": "rust", "repo": "rust-console/voladdress", "path": "/src/volseries.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-console/voladdress path: /src/volseries.rs use super::*; /// A volatile memory "series". /// /// This is intended to model when a portion of memory is a series of evenly /// spaced values that are *not* directly contiguous. /// /// ## Generic Parameters /// * `T` / `R` / `W`: These paramet...
code_fim
hard
{ "lang": "rust", "repo": "rust-console/voladdress", "path": "/src/volseries.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> write!(f, "VolSeries<{elem_ty}, r{readability}, w{writeability}, c{count}, s{stride:#X}>(0x{address:#X})", elem_ty = core::any::type_name::<T>(), readability=core::any::type_name::<R>(), writeability=core::any::type_name::<W>(), count=C, stride=S, address=self.base....
code_fim
hard
{ "lang": "rust", "repo": "rust-console/voladdress", "path": "/src/volseries.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if data%5 == 0 { //3==0 //false println!("{} is divisible by 5",data); } else { println!("{} is not divisible by 5",data); } let number =3; if number ==1 { println!("One"); } else if number ==2 { println!("Two"); } else if numb...
code_fim
hard
{ "lang": "rust", "repo": "aakhtar8/Quarter1_Batch3", "path": "/morning_oct27/ifelse/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aakhtar8/Quarter1_Batch3 path: /morning_oct27/ifelse/src/main.rs fn main() { //main start let check :u8 = 10; if check < 10 { println!("We are in if block"); } else { //if end else start println!("We are in ELse block"); } //else end let age =20; let...
code_fim
medium
{ "lang": "rust", "repo": "aakhtar8/Quarter1_Batch3", "path": "/morning_oct27/ifelse/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: imkgerC/rust-socha2020 path: /game_sdk/src/gamerules.rs use crate::action::Action; use crate::actionlist::ActionList; use crate::bitboard; use crate::bitboard::get_neighbours; use crate::gamestate::Color; use crate::gamestate::Color::{BLUE, RED}; use crate::gamestate::GameState; use crate::neigh...
code_fim
hard
{ "lang": "rust", "repo": "imkgerC/rust-socha2020", "path": "/game_sdk/src/gamerules.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // nowe let mut nowe = bitboard::shift_nowe(from); while nowe & occupied > 0 { nowe = bitboard::shift_nowe(nowe); } destinations |= nowe; // noea let mut noea = bitboard::shift_noea(from); while noea & occupied > 0 { noea = bitboard::shift_noea(noea); }...
code_fim
hard
{ "lang": "rust", "repo": "imkgerC/rust-socha2020", "path": "/game_sdk/src/gamerules.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.into_builder::<T>(bits).map(|builder| builder.into()) } fn into_builder<T: Encoding>(&self, bits: usize) -> Result<BuilderData> { if self.is_nan() { err!(ExceptionCode::RangeCheckError) } else { T::new(bits).try_serialize(self) } } ...
code_fim
hard
{ "lang": "rust", "repo": "NoamDev/rust-tvm", "path": "/src/stack/integer/serialization/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NoamDev/rust-tvm path: /src/stack/integer/serialization/mod.rs /* * Copyright 2018-2020 TON DEV SOLUTIONS LTD. * * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use * this file except in compliance with the License. * * Unless required by applicable law or agreed to...
code_fim
medium
{ "lang": "rust", "repo": "NoamDev/rust-tvm", "path": "/src/stack/integer/serialization/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hsharpsoftware/interop-fable-rust path: /src/main.rs #![feature(libc)] #![feature(link_args)] #[link_args = "-s EXPORTED_FUNCTIONS=['_app','_callback','_process_state']"] extern {} extern crate libc; use std::ffi::CString; use std::ffi::CStr; use libc::c_char; use std::mem; const STATE_INITI...
code_fim
hard
{ "lang": "rust", "repo": "hsharpsoftware/interop-fable-rust", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Serialize, Deserialize)] #[derive(Debug)] struct State { state : i32, person : Option<Person> } fn render_ui() -> String { eval_s("FableLib.render()") } fn convert_from_js( data : *mut c_char ) -> String { unsafe { let s = CString::from_raw(data); let s = s.into_...
code_fim
hard
{ "lang": "rust", "repo": "hsharpsoftware/interop-fable-rust", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: svenschmidt75/Rust path: /DSandAlg/CodingProblems/Swap2CharsInAEqualsB/src/lib.rs // https://www.reddit.com/r/AlgoExpert/comments/evoh1a/day_6_20200129_problem_of_the_day_asked_by_airbnb/ fn solve1(a: &str, b: &str) -> bool { // SS: runtime complexity: O(k^2), where k = length(a) = length(b...
code_fim
hard
{ "lang": "rust", "repo": "svenschmidt75/Rust", "path": "/DSandAlg/CodingProblems/Swap2CharsInAEqualsB/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test14() { // Arrange let a = "aaaaaaabc"; let b = "aaaaaaacb"; // Act let result = solve1(a, b); // Assert assert_eq!(result, true); } #[test] fn test15() { // Arrange let a = "abbc"; let b =...
code_fim
hard
{ "lang": "rust", "repo": "svenschmidt75/Rust", "path": "/DSandAlg/CodingProblems/Swap2CharsInAEqualsB/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Assert assert_eq!(result, true); } #[test] fn test24() { // Arrange let a = "aaaaaaabc"; let b = "aaaaaaacb"; // Act let result = solve2(a, b); // Assert assert_eq!(result, true); } #[test] fn test25() {...
code_fim
hard
{ "lang": "rust", "repo": "svenschmidt75/Rust", "path": "/DSandAlg/CodingProblems/Swap2CharsInAEqualsB/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> impl Arbitrary for PeerSpec { type Parameters = (); type Strategy = BoxedStrategy<Self>; fn arbitrary_with(_: Self::Parameters) -> Self::Strategy { ( any::<ProtocolVersion>(), option::of(any::<PeerAddr>()), option::of...
code_fim
hard
{ "lang": "rust", "repo": "ergoplatform/sigma-rust", "path": "/ergo-p2p/src/peer_spec.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ergoplatform/sigma-rust path: /ergo-p2p/src/peer_spec.rs //! PeerSpec types use std::io; use bounded_vec::BoundedVec; use ergo_chain_types::PeerAddr; use sigma_ser::vlq_encode::VlqEncodingError; use sigma_ser::{ScorexParsingError, ScorexSerializable, ScorexSerializeResult}; use crate::{peer_fe...
code_fim
hard
{ "lang": "rust", "repo": "ergoplatform/sigma-rust", "path": "/ergo-p2p/src/peer_spec.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> impl PeerSpec { /// Ensure the PeerSpec has a valid addr /// This can happen if declared_addr is none and there is no LocalAddressPeerFeature in features pub fn with_ensured_addr(mut self) -> Self { if self.addr().is_none() { let mut runner = TestRun...
code_fim
hard
{ "lang": "rust", "repo": "ergoplatform/sigma-rust", "path": "/ergo-p2p/src/peer_spec.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Create new, empty L-System. pub fn new() -> LSystem { LSystem { iteration_engine: IterationEngine::new(), interpretation_engine: InterpretationEngine::new(), parameters: DrawingParameters::new(), commands: Vec::new(), drawing_result: DrawingResult::new() } } /// Set the iterati...
code_fim
hard
{ "lang": "rust", "repo": "piedoom/lsystems-core", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: piedoom/lsystems-core path: /src/lib.rs // All features used for drawing, i.e. turtle implementation and primtive defintions pub mod drawing; // Iteration engine and support structures pub mod iteration; // Rule grammar pub mod grammar; // Various utilities pub mod util; // Interpretation of int...
code_fim
hard
{ "lang": "rust", "repo": "piedoom/lsystems-core", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn end_key(&self) -> Key { self.region.end_key.to_vec().into() } pub fn range(&self) -> (Key, Key) { (self.start_key(), self.end_key()) } pub fn ver_id(&self) -> RegionVerId { let region = &self.region; let epoch = region.region_epoch.as_ref().unwr...
code_fim
hard
{ "lang": "rust", "repo": "tikv/client-rust", "path": "/src/region.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tikv/client-rust path: /src/region.rs // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. use derive_new::new; use crate::proto::kvrpcpb; use crate::proto::metapb; use crate::Error; use crate::Key; use crate::Result; /// The ID of a region pub type RegionId = u64; /// The ID of...
code_fim
hard
{ "lang": "rust", "repo": "tikv/client-rust", "path": "/src/region.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }