text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f407/rtc/tr.rs #[doc = "Register `TR` reader"] pub struct R(crate::R<TR_SPEC>); impl core::ops::Deref for R { type Target = crate::R<TR_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f407/rtc/tr.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `ST` writer - Second tens in BCD format"] pub struct ST_W<'a> { w: &'a mut W, } impl<'a> ST_W<'a> { #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bits(self, value: u8) -> &'a mut W { self.w.bits = (self.w.bits & !(0x07 << 4...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f407/rtc/tr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `SU` writer - Second units in BCD format"] pub struct SU_W<'a> { w: &'a mut W, } impl<'a> SU_W<'a> { #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bits(self, value: u8) -> &'a mut W { self.w.bits = (self.w.bits & !0x0f) | (...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f407/rtc/tr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] #[derive(Clone, Copy)] #[derive(Eq, PartialEq, Ord, PartialOrd)] pub enum Rank { HighCard(HighCard), Pair(Pair), TwoPairs(TwoPairs), Trips(Trips), Straight(Straight), Flush(Flush), FullHouse(FullHouse), Quads(Quads), StraightFlush(StraightFlush) } imp...
code_fim
hard
{ "lang": "rust", "repo": "subdir/pkb", "path": "/src/rank/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: subdir/pkb path: /src/rank/mod.rs /// ``` /// use pokerbot::Value::*; /// use pokerbot::Rank; /// use pokerbot::rank::*; /// /// assert!( Rank::straight(Straight::new(Five)) < Rank::quads(Quads::new(Three, Two)) ); /// ``` mod intersect; mod distinct; mod distinct_ordered; mod distinct_ordered...
code_fim
hard
{ "lang": "rust", "repo": "subdir/pkb", "path": "/src/rank/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if day == 1 { ending = "st".to_string(); } else if day == 2 { ending = "nd".to_string(); } else if day == 3 { ending = "rd".to_string(); } else { ending = "th".to_string(); } println!("On the {}{} da...
code_fim
hard
{ "lang": "rust", "repo": "jonathan-hyland/rust_exercises", "path": "/concepts_test/concepts_test3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonathan-hyland/rust_exercises path: /concepts_test/concepts_test3.rs // Print the lyrics to the Christmas carol “The Twelve Days of Christmas,” taking advantage of the repetition in the song. fn main() { twelve_days() } fn twelve_days() { <|fim_suffix|> if day == 1 { ...
code_fim
hard
{ "lang": "rust", "repo": "jonathan-hyland/rust_exercises", "path": "/concepts_test/concepts_test3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dgoldsb/advent-of-code-2020 path: /rust/day_17/src/main.rs use aoc::parse_lines; use std::collections::HashSet; #[derive(Clone, Debug, Eq, Hash, PartialEq)] struct Block { x: isize, y: isize, z: isize, w: isize, } impl Block { fn neighbours(&self, part_a: &bool) -> HashSet<...
code_fim
hard
{ "lang": "rust", "repo": "dgoldsb/advent-of-code-2020", "path": "/rust/day_17/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut set = HashSet::new(); set.insert(Block { x: 0, y: 1, z: 0, w: 0, }); set.insert(Block { x: 1, y: 2, z: 0, w: 0, }); set.insert(Block { x: 2, ...
code_fim
hard
{ "lang": "rust", "repo": "dgoldsb/advent-of-code-2020", "path": "/rust/day_17/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut new_state = HashSet::new(); // Get all blocks that could be active next cycle. let mut under_consideration: HashSet<Block> = HashSet::new(); for block in previous_state.iter() { under_consideration.extend(block.neighbours(part_a)); } // For each, check if they wil...
code_fim
hard
{ "lang": "rust", "repo": "dgoldsb/advent-of-code-2020", "path": "/rust/day_17/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: linclelinkpart5/anagma path: /src/metadata/plexer.rs //! Methods to assign blocks of metadata to their corresponding item file paths. use std::borrow::Cow; use std::io::{Error as IoError, Result as IoResult}; use std::iter::FusedIterator; use std::path::Path; use std::path::PathBuf; use std::ve...
code_fim
hard
{ "lang": "rust", "repo": "linclelinkpart5/anagma", "path": "/src/metadata/plexer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let schema_one = Schema::One(block_a.clone()); let schema_seq = Schema::Seq(BlockSeq(vec![block_a.clone(), block_b.clone(), block_c.clone()])); let schema_map = Schema::Map(BlockMap(indexmap![ str!(name_c) => block_c.clone(), str!(name_a) => block_a.clone(),...
code_fim
hard
{ "lang": "rust", "repo": "linclelinkpart5/anagma", "path": "/src/metadata/plexer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // IO error. let mut plexer = Plexer::new( schema.clone(), vec![ Err(IoError::new(std::io::ErrorKind::Other, "sample")), okc(&path_a), ], &sorter, ); assert_io_error!(plexer); assert_ok!...
code_fim
hard
{ "lang": "rust", "repo": "linclelinkpart5/anagma", "path": "/src/metadata/plexer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ollikarppinen/advent-of-code-2020 path: /src/solutions/day1.rs use helpers; pub fn run () -> () { let target = 2020; let mut ls = helpers::ints_from_file("./day-1-input.txt"); ls.sort(); 'i: for i in 0..<|fim_suffix|> * c); break 'i; } else if...
code_fim
hard
{ "lang": "rust", "repo": "ollikarppinen/advent-of-code-2020", "path": "/src/solutions/day1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> * c); break 'i; } else if sum > target { break 'k; } } } } }<|fim_prefix|>// repo: ollikarppinen/advent-of-code-2020 path: /src/solutions/day1.rs use helpers; pub fn run () -> () { let target = 2020; ...
code_fim
hard
{ "lang": "rust", "repo": "ollikarppinen/advent-of-code-2020", "path": "/src/solutions/day1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let logger = slog_scope::logger(); set_network_config(&mut network_config, matches, &data_dir, &logger, true)?; let private_key = load_private_key(&network_config, &logger); let local_key = CombinedKey::from_libp2p(&private_key)?; let mut local_enr = create_enr_b...
code_fim
hard
{ "lang": "rust", "repo": "dpdanpittman/lighthouse", "path": "/boot_node/src/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dpdanpittman/lighthouse path: /boot_node/src/config.rs use beacon_node::{get_data_dir, set_network_config}; use clap::ArgMatches; use discv5::{enr::CombinedKey, Enr}; use eth2_libp2p::{ discovery::{create_enr_builder_from_config, use_or_load_enr}, load_private_key, CombinedKeyExt, Networ...
code_fim
hard
{ "lang": "rust", "repo": "dpdanpittman/lighthouse", "path": "/boot_node/src/config.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let boot_nodes = { if let Some(boot_nodes) = matches.value_of("boot-nodes") { boot_nodes .split(',') .map(|enr| enr.parse().map_err(|_| format!("Invalid ENR: {}", enr))) .collect::<Result<Vec<Enr>, _>>()? ...
code_fim
hard
{ "lang": "rust", "repo": "dpdanpittman/lighthouse", "path": "/boot_node/src/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kgv/rustapi path: /src/um/fileapi/query_dos_device.rs use crate::r#macro::FnOnce; use anyhow::{ensure, Result}; use itertools::Itertools; use log::warn; use std::{io, ptr::null}; use typed_builder::TypedBuilder; use widestring::{WideCStr, WideCString}; use winapi::{ self, shared::{minwin...
code_fim
hard
{ "lang": "rust", "repo": "kgv/rustapi", "path": "/src/um/fileapi/query_dos_device.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self::builder().build() } } impl FnOnce<()> for QueryDosDevice<'_> { type Output = Result<Vec<String>>; extern "rust-call" fn call_once(mut self, _args: ()) -> Self::Output { use winapi::um::fileapi::QueryDosDeviceW; let device_name = self.device_name.map(WideCString...
code_fim
hard
{ "lang": "rust", "repo": "kgv/rustapi", "path": "/src/um/fileapi/query_dos_device.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub mod view; mod base; pub use base::*; mod button; pub use button::*;<|fim_prefix|>// repo: paulotten/tuifw path: /src/lib.rs #![deny(warnings)] #![allow(clippy::collapsible_if)] #![allow(clippy::many_single_char_names)] #![allow(clippy::unit_arg)] #![allow(clippy::option_map_unit_fn)] <|fim_middle|...
code_fim
easy
{ "lang": "rust", "repo": "paulotten/tuifw", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paulotten/tuifw path: /src/lib.rs #![deny(warnings)] #![allow(clippy::collapsible_if)] #![allow(clippy::many_single_char_names)] #![allow(clippy::unit_arg)] #![allow(clippy::option_map_unit_fn)] pub use tuifw_screen_base::*; <|fim_suffix|>mod base; pub use base::*; mod button; pub use button:...
code_fim
easy
{ "lang": "rust", "repo": "paulotten/tuifw", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/parser/issue-20711.rs struct Foo; impl Foo { #[stable(feature =<|fim_suffix|>`extern`, `fn`, `pub`, `type`, or fn main() {}<|fim_middle|> "rust1", since = "1.0.0")] } //~ ERROR expected one of `async`, `const`, `crate`, `default`,
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/parser/issue-20711.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>`extern`, `fn`, `pub`, `type`, or fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/parser/issue-20711.rs struct Foo; impl Foo { #[stable(feature = "rust1", since = "1.0.0")] } //~ ERROR expecte<|fim_middle|>d one of `async`, `const`, `crate`, `default`,
code_fim
easy
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/parser/issue-20711.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dieggsy/project-euler path: /rust/src/bin/p097.rs use std::time::Instant; use rug::Integer; use rug::ops::*; <|fim_suffix|> let mut res: String = (Integer::from(28433) * Integer::from(2).pow(7830457) + Integer::from(1)) .to_string() .chars() .rev() .take(10) ...
code_fim
medium
{ "lang": "rust", "repo": "dieggsy/project-euler", "path": "/rust/src/bin/p097.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn optimize(&self, model: &mut TypedModel) -> TractResult<()> { self.session().optimize(model) } pub fn session(&self) -> OptimizerSession { OptimizerSession { optimizer: self, counter: 0, seen: Default::default() } } } #[derive(Debug)] pub struct OptimizerSession<'o>...
code_fim
hard
{ "lang": "rust", "repo": "sonos/tract", "path": "/core/src/optim/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sonos/tract path: /core/src/optim/mod.rs use crate::internal::*; use std::collections::HashSet; use std::fmt::Debug; use tract_itertools::Itertools; pub mod change_axes; mod op_optim; mod prop_const; mod push_split_down; mod slice; use self::change_axes::ChangeAxes; use self::prop_const::PropC...
code_fim
hard
{ "lang": "rust", "repo": "sonos/tract", "path": "/core/src/optim/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> followers::*; pub use models::*; pub use request::*; pub use tweets::*;<|fim_prefix|>// repo: kyasu1/kuon path: /src/lib.rs mod auth; mod client_builder; mod constants; mod errors; mod followers; <|fim_middle|>mod models; mod request; mod tweets; pub use client_builder::{Callback, ClientBuilder}; pub(c...
code_fim
medium
{ "lang": "rust", "repo": "kyasu1/kuon", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kyasu1/kuon path: /src/lib.rs mod auth; mod client_builder; mod constants; mod errors; mod followers; <|fim_suffix|> followers::*; pub use models::*; pub use request::*; pub use tweets::*;<|fim_middle|>mod models; mod request; mod tweets; pub use client_builder::{Callback, ClientBuilder}; pub(c...
code_fim
medium
{ "lang": "rust", "repo": "kyasu1/kuon", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ClientBuilder}; pub(crate) use constants::*; pub use errors::*; pub use followers::*; pub use models::*; pub use request::*; pub use tweets::*;<|fim_prefix|>// repo: kyasu1/kuon path: /src/lib.rs mod auth; mod client_builder; mod constants; mod errors; mod followers; <|fim_middle|>mod models; mod reques...
code_fim
medium
{ "lang": "rust", "repo": "kyasu1/kuon", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn span(&self) -> SourceSpan { SourceSpan::new(self.token_start, self.token_end) } fn slice(&self) -> &str { self.scanner.slice(self.span()) } fn skip_whitespace(&mut self) { while self.read().is_whitespace() { self.skip(); } } ...
code_fim
hard
{ "lang": "rust", "repo": "eirproject/eir", "path": "/util/libeir_util_parse_listing/src/token.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eirproject/eir path: /util/libeir_util_parse_listing/src/token.rs use std::str::FromStr; use libeir_diagnostics::*; use libeir_intern::Symbol; use libeir_ir::Integer; use libeir_util_parse::{Scanner, Source}; macro_rules! pop { ($lex:ident) => {{ $lex.skip(); }}; ($lex:iden...
code_fim
hard
{ "lang": "rust", "repo": "eirproject/eir", "path": "/util/libeir_util_parse_listing/src/token.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn pop(&mut self) -> char { let (pos, c) = self.scanner.pop(); self.token_end = pos + ByteOffset::from_char_len(c); c } fn peek(&mut self) -> char { self.scanner.peek().1 } fn read(&mut self) -> char { self.scanner.read().1 } fn skip(&...
code_fim
hard
{ "lang": "rust", "repo": "eirproject/eir", "path": "/util/libeir_util_parse_listing/src/token.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let port: u16 = matches .value_of("port") .unwrap_or("8080") .parse() .expect("Invalid port"); let store = memorystore! { "index.html" => "Welcome to TamaWiki.\n" }; let bind_to: SocketAddr = (address, port).into(); let server = Server::bind(&...
code_fim
hard
{ "lang": "rust", "repo": "t-pk/tamawiki", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: t-pk/tamawiki path: /src/main.rs #[macro_use] extern crate tamawiki; #[macro_use] extern crate clap; extern crate futures; extern crate hyper; use futures::future::Future; use hyper::Server; use std::net::{IpAddr, SocketAddr}; use tamawiki::store::memory::MemoryStore; use tamawiki::TamaWiki; f...
code_fim
medium
{ "lang": "rust", "repo": "t-pk/tamawiki", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Jasper-Bekkers/stochastic-data-structures path: /src/lib.rs extern crate rand; use rand::*; #[derive(Debug, Copy, Clone)] pub struct ExtractStats { pub loop_count: u32, pub group_iterations: Option<u32>, } pub trait StatisticalMethod<T> where T: Clone + Copy, { fn add(&mut sel...
code_fim
hard
{ "lang": "rust", "repo": "Jasper-Bekkers/stochastic-data-structures", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> alias.probability[a] = list[a]; alias.alias[a] = g as u32; list[g] = list[g] + list[a] - 1.0; if list[g] < 1.0 { small[num_small] = g; num_small += 1; } else { large[num_large] = g; ...
code_fim
hard
{ "lang": "rust", "repo": "Jasper-Bekkers/stochastic-data-structures", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut num_small = 0; let mut num_large = 0; for k in 0..list.len() { let i = list.len() - k - 1; if list[i] < 1.0 { small[num_small] = i; num_small += 1; } else { large[num_large] = i; ...
code_fim
hard
{ "lang": "rust", "repo": "Jasper-Bekkers/stochastic-data-structures", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl From<uuid::Uuid> for Uuidi128 { #[inline] fn from(u: uuid::Uuid) -> Self { Uuidi128(u) } } impl Serialize for Uuidi128 { fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where S: Serializer { let mut bytes = self...
code_fim
hard
{ "lang": "rust", "repo": "DarkWeird/mcproto-rs", "path": "/serde-mcproto/src/types/uuid.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'de> Deserialize<'de> for Uuidi128 { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de> { struct UUIDVisitor; impl<'a> Visitor<'a> for UUIDVisitor { type Value = Uuidi128; fn expecting(&self, formatter: &mut st...
code_fim
hard
{ "lang": "rust", "repo": "DarkWeird/mcproto-rs", "path": "/serde-mcproto/src/types/uuid.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DarkWeird/mcproto-rs path: /serde-mcproto/src/types/uuid.rs use serde::{Serialize, Serializer, Deserialize, Deserializer}; use serde::de::Visitor; #[derive(Debug, Clone)] pub struct Uuid(pub uuid::Uuid); impl Into<uuid::Uuid> for Uuid { #[inline] fn into(self) -> uuid::Uuid { s...
code_fim
hard
{ "lang": "rust", "repo": "DarkWeird/mcproto-rs", "path": "/serde-mcproto/src/types/uuid.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn parse_pattern_node_relationship_node() { let expected = Ok(( " data", Pattern(vec![ Entity::Node(Node { variable: Some("var1"), labels: vec![Label("ALabel")], properties: Some(Map...
code_fim
hard
{ "lang": "rust", "repo": "fabrlyn/cypherfmt", "path": "/src/pattern.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fabrlyn/cypherfmt path: /src/pattern.rs use nom::{combinator::map, multi::many1, IResult}; use crate::entity::Entity; #[derive(Debug, PartialEq)] pub struct Pattern<'a>(pub Vec<Entity<'a>>); impl<'a> Pattern<'a> { pub fn format(&self) -> String { format!( "{}", ...
code_fim
hard
{ "lang": "rust", "repo": "fabrlyn/cypherfmt", "path": "/src/pattern.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let dumps_dir = ::tempdir::TempDir::new_in(".", "dumps").unwrap(); let tmp_dir2 = ::tempdir::TempDir::new_in(".", "rocks").unwrap(); let dump_ok = DbDumpTool::new(&tmp_dir, dumps_dir.path().join("mydump")).run(&Options::default()); assert!(dump_ok); let undump_ok...
code_fim
hard
{ "lang": "rust", "repo": "andelf/rust-rocks", "path": "/src/db_dump_tool.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andelf/rust-rocks path: /src/db_dump_tool.rs //! Dump and un-dump tools for rocksdb use std::path::Path; use rocks_sys as ll; use options::Options; use to_raw::ToRaw; /// Dumps db to a ROCKDUMP file pub struct DbDumpTool { raw: *mut ll::rocks_dump_options_t, } impl Drop for DbDumpTool {...
code_fim
hard
{ "lang": "rust", "repo": "andelf/rust-rocks", "path": "/src/db_dump_tool.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> { let opt = Options::default().map_db_options(|db| db.create_if_missing(true)); let db = DB::open(opt, &tmp_dir).unwrap(); let mut batch = WriteBatch::new(); batch .put(b"key1", b"BYasdf1CQ") .put(b"key2", b"BYasdf1CQ"...
code_fim
hard
{ "lang": "rust", "repo": "andelf/rust-rocks", "path": "/src/db_dump_tool.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Entry style. pub entry: Entry } impl Default for Style { fn default() -> Self { Self { block: false, last: false, dashed: false, entry: Entry::Simple } } }<|fim_prefix|>// repo: lucas-miranda/tree_decorator path: /src/de...
code_fim
hard
{ "lang": "rust", "repo": "lucas-miranda/tree_decorator", "path": "/src/decorator/style.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lucas-miranda/tree_decorator path: /src/decorator/style.rs #[derive(Clone)] pub enum Entry { Simple, Double, None } /// A style to be applied to tree item. /// /// Each field, called style item, /// can be opt-in by using it's name at [`tree_item!`]. #[derive(Clone)] pub struct St...
code_fim
medium
{ "lang": "rust", "repo": "lucas-miranda/tree_decorator", "path": "/src/decorator/style.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut count:u8 = 0; let index_x:i32 = x as i32; let index_y:i32 = y as i32; /* check each square touching current square */ for i in (index_x - 1)...(index_x + 1){ for j in (index_y - 1)...(index_y + 1){ if i != index_x || j != index_y{...
code_fim
hard
{ "lang": "rust", "repo": "claytn/Game_Of_Life", "path": "/src/grid.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: claytn/Game_Of_Life path: /src/grid.rs /* Grid definition that holds both grids; one used as a buffer while other is updated */ pub struct Grid{ display: [[bool; 8]; 8], buffer: [[bool; 8]; 8] } impl Grid{ pub fn new(arr:[[bool; 8]; 8]) -> Grid{ Grid{ display: ar...
code_fim
hard
{ "lang": "rust", "repo": "claytn/Game_Of_Life", "path": "/src/grid.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn next(&mut self) { /* game of life logic */ for i in 0..8{ for j in 0..8{ let neighbors = self.num_neighbors(i,j); if neighbors >= 4 || neighbors <= 1{ /* kill cell */ self.buffer[i as usize][j as...
code_fim
hard
{ "lang": "rust", "repo": "claytn/Game_Of_Life", "path": "/src/grid.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: divarvel/s3-macaroon path: /src/credentials.rs use std::rc::Rc; use avro::{decode, encode, EnumSchema, EnumSymbol, Field, RecordSchema, Schema, Value}; use std::io::BufReader; #[derive(Debug)] pub enum S3SignatureVersion { V2, V4, } pub fn s3_signature_version_schema<'a>() -> EnumSchem...
code_fim
hard
{ "lang": "rust", "repo": "divarvel/s3-macaroon", "path": "/src/credentials.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn value_to_creds(v: Value) -> Result<Credentials, String> { match v { Value::Record(_, ref fields) => { if fields.len() == 5 { let ref key = fields[0]; let ref secret = fields[1]; let ref base = fields[2]; let ref...
code_fim
hard
{ "lang": "rust", "repo": "divarvel/s3-macaroon", "path": "/src/credentials.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn credentials_schema<'a>() -> RecordSchema<'a> { RecordSchema::new( "S3SignatureVersion".into(), None, vec![], vec![ Field { name: "access_key".into(), doc: None, properties: vec![], ty: Schema::String }, Field { name: "access_secret".into()...
code_fim
hard
{ "lang": "rust", "repo": "divarvel/s3-macaroon", "path": "/src/credentials.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ast().unwrap(); } let mut k = k; let mut ans = 0; for i in (0..=ve.len() - 1).rev() { if ve[i] <= k { ans += 1; k -= ve[i] } if k == 0 { return ans; } } ans }...
code_fim
hard
{ "lang": "rust", "repo": "bing050802/leetcode-rust-repo", "path": "/1414/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ans += 1; k -= ve[i] } if k == 0 { return ans; } } ans } }<|fim_prefix|>// repo: bing050802/leetcode-rust-repo path: /1414/main.rs impl Solution { pub fn find_min_fibonacci_numbers(k: i32) -> i32 { ...
code_fim
hard
{ "lang": "rust", "repo": "bing050802/leetcode-rust-repo", "path": "/1414/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bing050802/leetcode-rust-repo path: /1414/main.rs impl Solution { pub fn find_min_fibonacci_numbers(k: i32) -> i32 { let mut ve: Vec<i32> = vec![1; 1]; let mut f = 1; let mut <|fim_suffix|>ast().unwrap(); } let mut k = k; let mut ans = 0; ...
code_fim
hard
{ "lang": "rust", "repo": "bing050802/leetcode-rust-repo", "path": "/1414/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: github/codeql path: /shared/tree-sitter-extractor/src/generator/dbscheme.rs use std::collections::BTreeSet as Set; use std::fmt; use crate::generator::ql; /// Represents a distinct entry in the database schema. pub enum Entry<'a> { /// An entry defining a database table. Table(Table<'a...
code_fim
hard
{ "lang": "rust", "repo": "github/codeql", "path": "/shared/tree-sitter-extractor/src/generator/dbscheme.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Generates the dbscheme by writing the given dbscheme `entries` to the `file`. pub fn write(file: &mut dyn std::io::Write, entries: &[Entry]) -> std::io::Result<()> { for entry in entries { match entry { Entry::Case(case) => write!(file, "{}\n\n", case)?, Entry::Tabl...
code_fim
hard
{ "lang": "rust", "repo": "github/codeql", "path": "/shared/tree-sitter-extractor/src/generator/dbscheme.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // print hexadecimal println!( " hex {}{}{}", color::Fg(color::Blue), r.to_str_radix(16), style::Reset ); // print base64 let (_, byt) = r.to_bytes_be(); let b64 = base64::encode(&byt); println!(" b64 {}{}{}", color::Fg(color::Cyan), b64, st...
code_fim
hard
{ "lang": "rust", "repo": "arnaucube/konv", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arnaucube/konv path: /src/main.rs use clap::App; use termion::{color, style}; extern crate base64; extern crate hex; extern crate num_bigint; extern crate num_traits; use num_bigint::{BigInt, Sign}; fn main() { let matches = App::new("myapp") .version("0.0.1") .about("Conv...
code_fim
hard
{ "lang": "rust", "repo": "arnaucube/konv", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let or = BigInt::parse_bytes(inp.as_bytes(), 10).unwrap(); let (_, b) = or.to_bytes_be(); if bigendian { return BigInt::from_bytes_be(Sign::Plus, &b); } BigInt::from_bytes_le(Sign::Plus, &b) }<|fim_prefix|>// repo: arnaucube/konv path: /src/main.rs use clap::App; use termion:...
code_fim
hard
{ "lang": "rust", "repo": "arnaucube/konv", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let movecount = moves.len(); let mv = if movecount == 1 { moves.remove(0) } else { moves.remove(rng.gen_range(0, movecount - 1)) }; board.do_move(mv); if board.game_result().is_some() { break; ...
code_fim
hard
{ "lang": "rust", "repo": "MortenLohne/rasher", "path": "/src/tests/tools.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MortenLohne/rasher path: /src/tests/tools.rs use board_game_traits::board::Board; #[cfg(test)] use pgn_traits::pgn::PgnBoard; #[cfg(test)] use rand::Rng; #[cfg(test)] use std::fmt::Debug; /// Returns how many moves the move generator finds after after searching `depth` plies deep. /// This prov...
code_fim
hard
{ "lang": "rust", "repo": "MortenLohne/rasher", "path": "/src/tests/tools.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let configuration = get_configuration().expect("Failed to read configuration"); let address = format!("0.0.0.0:{}", configuration.application_port); let listener = TcpListener::bind(address).expect("Failed to bind port"); run( listener, configuration.oauth.audience, ...
code_fim
hard
{ "lang": "rust", "repo": "dantdj/RustAuthZ", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> run( listener, configuration.oauth.audience, configuration.oauth.issuer, )? .await }<|fim_prefix|>// repo: dantdj/RustAuthZ path: /src/main.rs use rust_authz::{configuration::get_configuration, startup::run}; use std::net::TcpListener; use tracing::subscriber::set_glo...
code_fim
hard
{ "lang": "rust", "repo": "dantdj/RustAuthZ", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dantdj/RustAuthZ path: /src/main.rs use rust_authz::{configuration::get_configuration, startup::run}; use std::net::TcpListener; use tracing::subscriber::set_global_default; use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer}; use tracing_subscriber::{layer::SubscriberExt, E...
code_fim
hard
{ "lang": "rust", "repo": "dantdj/RustAuthZ", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn validate(e: Employee) { match e { Employee::Engineer => println!("is an engineer."), Employee::Manager => println!("is a manager."), Employee::Level(i) => println!("is at level {}.", i), Employee::Salary(i) => println!("has a salary {}.", i), Employee::In...
code_fim
hard
{ "lang": "rust", "repo": "mandliya/exploring-rust", "path": "/enums.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let ravi = Employee::Engineer; let chhaya = Employee::Manager; let arpit = Employee::Info {name: "Arpit".to_owned(), id: 123}; let saloni = Employee::Salary(100000); let satya = Employee::Level(100); validate(ravi); validate(chhaya); validate(arpit); valida...
code_fim
hard
{ "lang": "rust", "repo": "mandliya/exploring-rust", "path": "/enums.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mandliya/exploring-rust path: /enums.rs // Unlike C, Enums in Rust can be names, tuple structs or just structs. // It can be any of the possible variants. Each variants can optionally have data associated with it. // For example Level below. // enum Employee { // Unit like structus Eng...
code_fim
hard
{ "lang": "rust", "repo": "mandliya/exploring-rust", "path": "/enums.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(feature = "sm-winit")] pub fn from_winit_window(_: &Window) -> Result<Connection, Error> { Connection::new() } }<|fim_prefix|>// repo: kaitk/surfman path: /surfman/src/platform/windows/angle/connection.rs // surfman/surfman/src/platform/windows/angle/connection.rs // //! A conne...
code_fim
hard
{ "lang": "rust", "repo": "kaitk/surfman", "path": "/surfman/src/platform/windows/angle/connection.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaitk/surfman path: /surfman/src/platform/windows/angle/connection.rs // surfman/surfman/src/platform/windows/angle/connection.rs // //! A connection to the window server. //! //! It might seem like this should wrap an `EGLDisplay`, but it doesn't. Unfortunately, in the //! ANGLE implementation...
code_fim
medium
{ "lang": "rust", "repo": "kaitk/surfman", "path": "/surfman/src/platform/windows/angle/connection.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_catch_first() { test_utils::JVM_ENV.with(|env| { assert_eq!( test_catch( &env, Some("java/lang/IllegalArgumentException"), Err(Error::JavaException), false, ...
code_fim
hard
{ "lang": "rust", "repo": "gedgygedgy/jni-utils-rs", "path": "/rust/exceptions.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gedgygedgy/jni-utils-rs path: /rust/exceptions.rs vides methods to get /// and take the associated [`Any`]. /// /// Looks up the class and method IDs on creation rather than for every method /// call. pub struct JPanicException<'a: 'b, 'b> { internal: JThrowable<'a>, env: &'b JNIEnv<'a>,...
code_fim
hard
{ "lang": "rust", "repo": "gedgygedgy/jni-utils-rs", "path": "/rust/exceptions.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> test_utils::JVM_ENV.with(|env| { use jni::{objects::JString, strings::JavaStr}; use std::any::Any; const STRING_MSG: &'static str = "This is a String"; let ex = super::JPanicException::new(env, Box::new(STRING_MSG.to_string())).unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "gedgygedgy/jni-utils-rs", "path": "/rust/exceptions.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Sunspar/gw2rs path: /src/anet/achievement/group.rs use ::anet::achievement::category::AchievementCategoryId; <|fim_suffix|>/// `AchievementGroup`s represent broad groupings of achievements in Guild Wars 2. #[derive(Debug, Serialize, Deserialize)] pub struct AchievementGroup { pub id: Achiev...
code_fim
easy
{ "lang": "rust", "repo": "Sunspar/gw2rs", "path": "/src/anet/achievement/group.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// `AchievementGroup`s represent broad groupings of achievements in Guild Wars 2. #[derive(Debug, Serialize, Deserialize)] pub struct AchievementGroup { pub id: AchievementGroupId, pub name: String, pub description: String, pub order: u64, pub categories: Vec<AchievementCategoryId>, }...
code_fim
easy
{ "lang": "rust", "repo": "Sunspar/gw2rs", "path": "/src/anet/achievement/group.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IreneKnapp/2020-advent-of-code path: /lib/src/lib.rs pub mod error; pub mod prelude; pub use crate::prelude::Result; use std::fs::File; use std::io::BufReader; use std::io::prelude::*; pub fn greeting() -> Result<()> { println!("Hello, Irenes!"); Ok(()) } pub fn read_lines_file(filenam...
code_fim
hard
{ "lang": "rust", "repo": "IreneKnapp/2020-advent-of-code", "path": "/lib/src/lib.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> buffer.clear(); } Ok(input) } pub fn group_lines_by_blanks(lines: Vec<String>) -> Vec<Vec<String>> { let mut all_groups = Vec::new(); let mut current_group = Vec::new(); for line in lines { if line.len() == 0 { all_groups.push(current_group); current_group = Vec::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "IreneKnapp/2020-advent-of-code", "path": "/lib/src/lib.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|>pub fn read_int_file(filename: &str) -> Result<Vec<i64>> { let file = File::open(filename)?; let mut reader = BufReader::new(file); let mut buffer = String::new(); let mut input: Vec<i64> = Vec::new(); loop { reader.read_line(&mut buffer)?; if buffer.len() == 0 { break; } ...
code_fim
hard
{ "lang": "rust", "repo": "IreneKnapp/2020-advent-of-code", "path": "/lib/src/lib.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> let ast_fields: HashSet<_> = self.fields.iter().map(|f| f.field_name()).collect(); let schema_fields: HashSet<_, _> = schema.fields.iter().map(|f| f.name.to_owned()).collect(); if ast_fields == schema_fields { Ok(()) } else if ast_fields.is_subset(...
code_fim
hard
{ "lang": "rust", "repo": "RustWorks/openapi_to_rust", "path": "/src/internals/check.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustWorks/openapi_to_rust path: /src/internals/check.rs use crate::internals::ast::{EnumContainer, StructContainer}; use crate::internals::error::CheckFailure; use crate::internals::schema::{EnumSchema, StructSchema}; use crate::internals::Error; use std::collections::HashSet; pub trait Check<S...
code_fim
hard
{ "lang": "rust", "repo": "RustWorks/openapi_to_rust", "path": "/src/internals/check.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xenoterracide/brix path: /crates/brix_processor/src/helpers/basic.rs // Copyright (c) 2021 Ethan Lerner, Caleb Cushing, and the Brix contributors // // This software is released under the MIT License. // https://opensource.org/licenses/MIT //! Contains the [ToUpperHelper], [ToLowerHelper], and ...
code_fim
hard
{ "lang": "rust", "repo": "xenoterracide/brix", "path": "/crates/brix_processor/src/helpers/basic.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl HelperDef for ToJavaPackagePathHelper { fn call<'reg: 'rc, 'rc>( &self, h: &Helper, _: &Handlebars, _: &Context, _rc: &mut RenderContext, out: &mut dyn Output, ) -> HelperResult { let param = h.param(0).ok_or(RenderError::new( ...
code_fim
hard
{ "lang": "rust", "repo": "xenoterracide/brix", "path": "/crates/brix_processor/src/helpers/basic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut docker_compose = NamedTempFile::new()?; writeln!( docker_compose, "services: hello_1: image: docker.io/alpine:3.13.2 hello_2: image: docker.io/alpine:3.13.2 hello_3: image: docker.io/alpine:3.13.2 ...
code_fim
hard
{ "lang": "rust", "repo": "evant/docker-compose-test", "path": "/tests/cli.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: evant/docker-compose-test path: /tests/cli.rs use std::error::Error; use std::io::Write; use std::process::Command; use assert_cmd::assert::OutputAssertExt; use assert_cmd::cargo::CommandCargoExt; use predicates::boolean::PredicateBooleanExt; use predicates::str::contains; use serial_test::seri...
code_fim
hard
{ "lang": "rust", "repo": "evant/docker-compose-test", "path": "/tests/cli.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> cmd.assert().failure().stdout(contains("hello 2")); Ok(()) } #[test] #[serial] fn verbose_includes_other_service_output() -> Result { let mut docker_compose = NamedTempFile::new()?; writeln!( docker_compose, "services: hello_1: image: docker.io/alp...
code_fim
hard
{ "lang": "rust", "repo": "evant/docker-compose-test", "path": "/tests/cli.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kingoflolz/althea_rs path: /althea_kernel_interface/src/stats.rs use super::KernelInterface; use failure::Error; use std::fs::File; use std::io::Read; impl KernelInterface { pub fn get_proc_stat(&self) -> Result<String, Error> { debug!("getting proc stat"); let mut f = File...
code_fim
hard
{ "lang": "rust", "repo": "kingoflolz/althea_rs", "path": "/althea_kernel_interface/src/stats.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut contents = String::new(); f.read_to_string(&mut contents)?; Ok(contents) } pub fn get_cpuinfo_stats(&self) -> Result<String, Error> { debug!("getting cpuinfo"); let mut f = File::open("/proc/cpuinfo")?; let mut contents = String::new(); ...
code_fim
medium
{ "lang": "rust", "repo": "kingoflolz/althea_rs", "path": "/althea_kernel_interface/src/stats.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Verdex/dyn path: /src/lexer.rs use super::data::Token; use regex::Regex; #[derive(Debug)] enum AccumState { Consume, SingleQuoteString(Vec<char>), DoubleQuoteString(Vec<char>), Number(Vec<char>), Symbol(Vec<char>), Op(Vec<char>), } #[derive(Debug)] struct TokenAccum { ...
code_fim
hard
{ "lang": "rust", "repo": "Verdex/dyn", "path": "/src/lexer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn consume_until(mut buffer : Vec<char>, char_index : (usize, char), mut tokens : Vec<Token>, stop : impl Fn(char) -> bool, cons : impl Fn(String) -> Token, next : impl Fn(Vec<Token>, Vec<char>) -> TokenAccum ) -> Token...
code_fim
hard
{ "lang": "rust", "repo": "Verdex/dyn", "path": "/src/lexer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn should_handle_number_with_decimal() { let text = String::from(r#"1234.5678"#); let o = lex(text); assert_eq!(o.len(), 1); match &o[0] { Token::Number(n) => assert_eq!(n, "1234.5678"), _ => assert!(false, "Not a number."), ...
code_fim
hard
{ "lang": "rust", "repo": "Verdex/dyn", "path": "/src/lexer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mattwoodyard/proxykit path: /src/piece_buf.rs use bytes::{Bytes}; use std::rc::Rc; /** * Slice's are offsets into a Bytes which have a * "reference" to their underlying Bytes * they are not Send (although, really there isn't a * a reason they can't be Arc instead * This is in a file ca...
code_fim
hard
{ "lang": "rust", "repo": "mattwoodyard/proxykit", "path": "/src/piece_buf.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn from_parse_pair(base: Rc<Bytes>, st: usize, ln: usize) -> Slice { Slice { bytes: base, start: st, end: st + ln } } } #[cfg(test)] mod tests { // use super::*; }<|fim_prefix|>// repo: mattwoodyard/proxykit path: /src/piece_buf.rs use bytes::{Bytes}; use std::rc::Rc; /** *...
code_fim
hard
{ "lang": "rust", "repo": "mattwoodyard/proxykit", "path": "/src/piece_buf.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cep21/gambling path: /src/cards/card.rs use cards::suit::Suit; use cards::value::Value; use std::fmt; // Can I pass a ref? Or pointer? #[derive(Clone, Copy)] pub struct Card { v: Value, s: Suit, } <|fim_suffix|>impl PartialEq for Card { fn eq(&self, other: &Card) -> bool { ...
code_fim
medium
{ "lang": "rust", "repo": "cep21/gambling", "path": "/src/cards/card.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.v == other.v && self.s == other.s } } impl Card { pub fn suit(&self) -> &Suit { return &self.s; } pub fn value(&self) -> &Value { return &self.v; } pub fn new(v: Value, s: Suit) -> Card { return Card { v: v, s: s, ...
code_fim
medium
{ "lang": "rust", "repo": "cep21/gambling", "path": "/src/cards/card.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } /// See docs on [crate::clear_cache] for a description of what this function is trying to do. #[inline] pub(crate) fn clear_cache(ptr: *const c_void, len: usize) -> Result<()> { // See: // * https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/wasmtime", "path": "/crates/jit-icache-coherence/src/win.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /crates/jit-icache-coherence/src/win.rs use std::ffi::c_void; use std::io::{Error, Result}; use windows_sys::Win32::System::Diagnostics::Debug::FlushInstructionCache; use windows_sys::Win32::System::Threading::FlushProcessWriteBuffers; use windows_sys::Win32::Syst...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/wasmtime", "path": "/crates/jit-icache-coherence/src/win.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>/// See docs on [crate::clear_cache] for a description of what this function is trying to do. #[inline] pub(crate) fn clear_cache(ptr: *const c_void, len: usize) -> Result<()> { // See: // * https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-flushinstructi...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/wasmtime", "path": "/crates/jit-icache-coherence/src/win.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> let input_context_1 = "The quick brown fox jumps over the lazy dog"; let input_context_2 = "The dog did not wake up"; let outputs = model.translate(&[input_context_1, input_context_2], None, Language::French)?; assert_eq!(outputs.len(), 2); assert_eq!( outputs[0], " L...
code_fim
hard
{ "lang": "rust", "repo": "guillaume-be/rust-bert", "path": "/tests/marian.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }