text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>impl Globals { pub fn get<V: rlp::Decodable>(name: &str) -> Option<V> { get(name.as_bytes()) .map( |x| rlp::decode(&x).unwrap() ) } pub fn insert<V: rlp::Encodable>(key: &str, value: &V) { insert(key.as_bytes(), &rlp::encode(value)) ...
code_fim
hard
{ "lang": "rust", "repo": "TrustedDataFramework/smart-contract-rust-exmaple", "path": "/wbi/src/db.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn insert(key: &[u8], value: &[u8]) { let k = to_vec!(key); let v = to_vec!(value); unsafe { _db(Op::SET as u64, forget(k) as u64, forget(v) as u64); } } pub fn contains_key(key: &[u8]) -> bool { let k = to_vec!(key); unsafe { _db(Op::HAS as u64, forget(k) as ...
code_fim
hard
{ "lang": "rust", "repo": "TrustedDataFramework/smart-contract-rust-exmaple", "path": "/wbi/src/db.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("SlabRef") } fn visit_seq<V>(self, mut visitor: V) -> Result<SlabRef, V::Error> where V: SeqVisitor { let slab_id: SlabId = match visitor.visit()? { Some(value) => ...
code_fim
hard
{ "lang": "rust", "repo": "dnorman/unbase", "path": "/crates/unbase/src/slab/slabref/serde.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dnorman/unbase path: /crates/unbase/src/slab/slabref/serde.rs use crate::util::serde::*; // use network::TransportAddress; use super::*; impl StatefulSerialize for SlabRef { fn serialize<S>(&self, serializer: S, helper: &SerializeHelper) -> Result<S::Ok, S::Error> where S: Serialize...
code_fim
hard
{ "lang": "rust", "repo": "dnorman/unbase", "path": "/crates/unbase/src/slab/slabref/serde.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wiltonruntime/wilton_examples path: /rust/src/lib.rs /* * Copyright 2018, alex at staticlibs.net * * 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....
code_fim
hard
{ "lang": "rust", "repo": "wiltonruntime/wilton_examples", "path": "/rust/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub extern "C" fn wilton_module_init() -> *mut std::os::raw::c_char { // register a call for JavaScript let res1 = wilton_rusty::register_wiltocall("example_hello", |obj: MyObj1| { hello(obj) }); // check for error if res1.is_err() { return wilton_rusty::create_wilto...
code_fim
hard
{ "lang": "rust", "repo": "wiltonruntime/wilton_examples", "path": "/rust/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn hello_panic(_: MyObj1) -> MyObj2 { panic!("Some error message"); } // this function is called on module load #[no_mangle] pub extern "C" fn wilton_module_init() -> *mut std::os::raw::c_char { // register a call for JavaScript let res1 = wilton_rusty::register_wiltocall("example_hello", ...
code_fim
hard
{ "lang": "rust", "repo": "wiltonruntime/wilton_examples", "path": "/rust/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32h5/src/stm32h503/i3c1/i3c_getmxdsr.rs #[doc = "Register `I3C_GETMXDSR` reader"] pub type R = crate::R<I3C_GETMXDSR_SPEC>; #[doc = "Register `I3C_GETMXDSR` writer"] pub type W = crate::W<I3C_GETMXDSR_SPEC>; #[doc = "Field `HOFFAS` reader - controller hand-o...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h5/src/stm32h503/i3c1/i3c_getmxdsr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>and format 2 (with MaxRdTurn). This bit is used to return the 2-byte format 1 (MaxWr, MaxRd) or 5-byte format 2 (MaxWr, MaxRd, 3-byte MaxRdTurn) byte in response to the GETCAPS CCC. - 3-byte MaxRdTurn is returned with MSB=0, middle byte=0 and LSB=RDTURN\\[7:0\\]. - Max read turnaround time is less than 25...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h5/src/stm32h503/i3c1/i3c_getmxdsr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AzzOnFire/simple-raytracing path: /src/ray.rs use crate::Vec3; use num::Float; #[derive(Eq, PartialEq, Clone, Hash, Debug, Copy)] pub struct Ray<T: Float> { origin: Vec3<T>, direction: Vec3<T>, } #[derive(Eq, PartialEq, Clone, Hash, Debug, Copy)] pub struct Intersection<T: Float> { ...
code_fim
medium
{ "lang": "rust", "repo": "AzzOnFire/simple-raytracing", "path": "/src/ray.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn direction(&self) -> &Vec3<T> { &self.direction } pub fn point_at_parameter(&self, t: T) -> Vec3<T> { let new: Vec3<T> = self.origin.clone(); new + self.direction * t } }<|fim_prefix|>// repo: AzzOnFire/simple-raytracing path: /src/ray.rs use crate::Vec3; ...
code_fim
hard
{ "lang": "rust", "repo": "AzzOnFire/simple-raytracing", "path": "/src/ray.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..=3 { let volume = controller.get_volume(VolumeIdx(i)); usbserial_write!("volume {:?}\r\n", volume); if let Ok(volume) = volume { let root_dir = controller.open_root_dir(&volume).unwrap(); usbser...
code_fim
hard
{ "lang": "rust", "repo": "atsamd-rs/atsamd", "path": "/boards/feather_m0/examples/adalogger.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: atsamd-rs/atsamd path: /boards/feather_m0/examples/adalogger.rs #![no_std] #![no_main] #[cfg(not(feature = "use_semihosting"))] use panic_halt as _; #[cfg(feature = "use_semihosting")] use panic_semihosting as _; use core::fmt::Write; use core::sync::atomic; use cortex_m::interrupt::free as d...
code_fim
hard
{ "lang": "rust", "repo": "atsamd-rs/atsamd", "path": "/boards/feather_m0/examples/adalogger.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if sd_cd.is_low().unwrap() { usbserial_write!("No card detected. Waiting...\r\n"); while sd_cd.is_low().unwrap() { delay.delay_ms(250_u32); } } usbserial_write!("Card inserted!\r\n"); delay.delay_ms(250_u32); let mut controller = Controller::new(SdM...
code_fim
hard
{ "lang": "rust", "repo": "atsamd-rs/atsamd", "path": "/boards/feather_m0/examples/adalogger.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: meganehouser/listening-tracker path: /track-importer/src/models.rs //! All kinds of play object use chrono::prelude::*; use std::collections::HashMap; use serde_derive::{Serialize, Deserialize}; <|fim_suffix|>#[derive(Clone, Debug, Serialize, Deserialize)] pub struct SimplifiedTrack { pub a...
code_fim
medium
{ "lang": "rust", "repo": "meganehouser/listening-tracker", "path": "/track-importer/src/models.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone, Debug, Serialize, Deserialize)] pub struct PlayHistory { pub track: SimplifiedTrack, pub played_at: DateTime<Utc>, pub context: Option<Context>, }<|fim_prefix|>// repo: meganehouser/listening-tracker path: /track-importer/src/models.rs //! All kinds of play object use chrono::...
code_fim
hard
{ "lang": "rust", "repo": "meganehouser/listening-tracker", "path": "/track-importer/src/models.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>define_task!( /// This [`Task`](crate::scheduling::Task) advances the orientation /// of all entities with angluar velocities by one time step. [pub] AdvanceOrientations, depends_on = [], execute_on = [PhysicsTag], |world: &World| { with_debug_logging!("Advancing orientatio...
code_fim
hard
{ "lang": "rust", "repo": "lars-frogner/Impact", "path": "/src/physics/motion/systems.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lars-frogner/Impact path: /src/physics/motion/systems.rs //! Tasks representing ECS systems related to motion. use crate::{ define_task, physics::{ self, AngularVelocityComp, OrientationComp, PhysicsTag, PositionComp, Static, VelocityComp, }, world::World, }; use impact_...
code_fim
hard
{ "lang": "rust", "repo": "lars-frogner/Impact", "path": "/src/physics/motion/systems.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(a.buf, "Hello, World!".as_bytes()); } #[test] fn write_test3() { let mut a: A = A::new(); let arg1: &'static str = "Hello"; let arg2: &'static str = "World"; let result: fmt::Result = write!(a, "{}, {}!", arg1, arg2); // invoked A::write_fmt match result { Ok(()) => ass...
code_fim
hard
{ "lang": "rust", "repo": "rick68/rust-trace", "path": "/libcore/macros/write.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rick68/rust-trace path: /libcore/macros/write.rs #![feature(core, collections)] extern crate core; extern crate collections; #[cfg(test)] mod tests { use core::fmt; use core::fmt::Write; use collections::vec::Vec; // macro_rules! write { // ($dst:expr, $($arg:tt)*) => ...
code_fim
hard
{ "lang": "rust", "repo": "rick68/rust-trace", "path": "/libcore/macros/write.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> components } fn visit_forward<'a>(graph: &'a Graph, visited: &mut HashSet<&'a VertexId>, vertex: &'a Vertex) -> Vec<&'a VertexId> { visited.insert(vertex.id()); let mut component: Vec<&VertexId> = Vec::new(); let neighbours = graph.get_neighbours(vertex); f...
code_fim
hard
{ "lang": "rust", "repo": "VuQuangPhuc/GraphLib-Rust", "path": "/src/graph/components.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VuQuangPhuc/GraphLib-Rust path: /src/graph/components.rs use crate::graph::Graph; use crate::graph::vertex::VertexId; use std::fs::File; use std::io::{LineWriter, Write}; pub fn find_connected_components(graph: &Graph) -> Vec<Vec<&VertexId>> { undirected_graph::find_connected_component(grap...
code_fim
hard
{ "lang": "rust", "repo": "VuQuangPhuc/GraphLib-Rust", "path": "/src/graph/components.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> visited.insert(vertex.id()); let neighbours = graph.reachable_vertices(vertex); for neighbour in neighbours { if !visited.contains(neighbour.id()) { visit_forward(graph, visited, vertex_stack, neighbour); } } vertex_stack.push...
code_fim
hard
{ "lang": "rust", "repo": "VuQuangPhuc/GraphLib-Rust", "path": "/src/graph/components.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Display for CompileMeta { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Tuple { tuple, .. } => { write!(fmt, "struct {}", tuple.item)?; } Self::TupleVariant { tuple, .. } => { write!...
code_fim
hard
{ "lang": "rust", "repo": "killercup/rune", "path": "/crates/runestick/src/compile_meta.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: killercup/rune path: /crates/runestick/src/compile_meta.rs use crate::collections::HashSet; use crate::{Hash, Item, Type}; use std::fmt; use std::sync::Arc; /// Metadata about a closure. #[derive(Debug, Clone)] pub struct CompileMetaCapture { /// Identity of the captured variable. pub i...
code_fim
hard
{ "lang": "rust", "repo": "killercup/rune", "path": "/crates/runestick/src/compile_meta.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let tags = if card.tags.is_empty() { None } else { Some(card.tags) }; Self { id: card.id, author_id: card.author_id, title: card.title, created_at: card.created_at, updated_at: card.updated...
code_fim
medium
{ "lang": "rust", "repo": "azinit/backend", "path": "/db/src/entities/card.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: azinit/backend path: /db/src/entities/card.rs use cardbox_core::models; use chrono::{DateTime, Utc}; use uuid::Uuid; #[derive(Debug, sqlx::FromRow, sqlx::Type)] pub(crate) struct Card { pub(crate) id: Uuid, pub(crate) author_id: Uuid, pub(crate) title: String, pub(crate) created...
code_fim
medium
{ "lang": "rust", "repo": "azinit/backend", "path": "/db/src/entities/card.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl From<models::Card> for Card { fn from(card: models::Card) -> Self { let tags = if card.tags.is_empty() { None } else { Some(card.tags) }; Self { id: card.id, author_id: card.author_id, title: card.title, ...
code_fim
hard
{ "lang": "rust", "repo": "azinit/backend", "path": "/db/src/entities/card.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/metal/src/mps.rs he data contained in an intersection result . / / / / / / See < https : / / developer . apple . com / documentation / metalperformanceshaders / mpsintersectiondatatype > pub enum MPSIntersectionDataType { Distance = 0 DistanceP...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/metal/src/mps.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/metal/src/mps.rs tive mask & ray mask ) ! = 0 . NotAnd = 1 / / / Accept the intersection if ( primitive mask | ray mask ) ! = 0 . Or = 2 / / / Accept the intersection if ~ ( primitive mask | ray mask ) ! = 0 . NotOr = 3 / / / Accept the interse...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/metal/src/mps.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> & self ) - > MPSAccelerationStructureStatus { unsafe { msg_send ! [ self status ] } } pub fn usage ( & self ) - > MPSAccelerationStructureUsage { unsafe { msg_send ! [ self usage ] } } pub fn set_usage ( & self usage : MPSAccelerationStructureUsage ) { unsafe { msg_send ! [ self setUsage : usage ] } } pu...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/metal/src/mps.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vramana/zebra path: /zebra-state/src/tests.rs use std::ffi::OsStr; use zebra_chain::{block, parameters::Network}; use super::*; #[test] fn test_path_mainnet() { test_path(Network::Mainnet); } #[test] fn test_path_testnet() { test_path(Network::Testnet); } /// Check the sled path for...
code_fim
hard
{ "lang": "rust", "repo": "vramana/zebra", "path": "/zebra-state/src/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(!locator.is_empty(), "locators must not be empty"); if (height - min_height) > 1 { assert!( locator.len() > 2, "non-trivial locators must have some intermediate heights" ); } assert_eq!( locator[0]...
code_fim
hard
{ "lang": "rust", "repo": "vramana/zebra", "path": "/zebra-state/src/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(combination(4, 2), 6); assert_eq!(combination(6, 2), 15); } #[test] fn each_digit() { assert_eq!(EachDigit::new(334).collect::<Vec<_>>(), vec![4, 3, 3]); assert_eq!( EachDigit::new(BigInt::from(334)).collect::<Vec<_>>(), vec![4.into(), 3.into(), 3.into()] ); } #[test] fn...
code_fim
hard
{ "lang": "rust", "repo": "komori-n/ProjectEuler-rs", "path": "/src/number_misc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn is_palindromic_test() { assert!(is_palindromic(2772)); assert!(is_palindromic(272)); assert!(!is_palindromic(334)); } #[test] fn factorial_test() { assert_eq!(factorial(4), 24); } #[test] fn combination_test() { assert_eq!(combination(4, 2), 6); assert_eq!(combination(6, 2...
code_fim
hard
{ "lang": "rust", "repo": "komori-n/ProjectEuler-rs", "path": "/src/number_misc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: komori-n/ProjectEuler-rs path: /src/number_misc.rs use memoise::memoise; use num::{Integer, One, Zero}; use std::cmp::PartialOrd; use std::ops::{Div, Rem}; pub fn is_palindromic(n: u64) -> bool { let n_str = format!("{}", n); let rev_str: String = n_str.chars().rev().collect(); n_str == rev...
code_fim
hard
{ "lang": "rust", "repo": "komori-n/ProjectEuler-rs", "path": "/src/number_misc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dunnock/linfa path: /tonic-linfa-k-means/src/main.rs use std::path::PathBuf; use structopt::StructOpt; use tonic::transport::Server; use tonic_linfa_k_means::server::{ClusteringServiceServer, KMeansProto}; use tonic_linfa_k_means::Store; <|fim_suffix|> let (n_centroids, n_features) = store.c...
code_fim
hard
{ "lang": "rust", "repo": "dunnock/linfa", "path": "/tonic-linfa-k-means/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Initialize server let addr = format!("[::1]:{}", opt.port).parse()?; let kmeans = KMeansProto::new(store); println!("Starting server on {}", &addr); Server::builder() .add_service(ClusteringServiceServer::new(kmeans)) .serve(addr) .await?; Ok(()) }<|fim_...
code_fim
hard
{ "lang": "rust", "repo": "dunnock/linfa", "path": "/tonic-linfa-k-means/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: actix/examples path: /basics/static-files/src/main.rs use actix_files::Files; use actix_web::{middleware::Logger, App, HttpServer}; #[actix_web::main] async fn main() -> std::io::Result<()> { env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); <|fim_suffix|> Htt...
code_fim
medium
{ "lang": "rust", "repo": "actix/examples", "path": "/basics/static-files/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> HttpServer::new(|| { App::new() // We allow the visitor to see an index of the images at `/images`. .service(Files::new("/images", "static/images/").show_files_listing()) // Serve a tree of static files at the web root and specify the index file. ...
code_fim
medium
{ "lang": "rust", "repo": "actix/examples", "path": "/basics/static-files/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: takagiy/senklot path: /src/state.rs use anyhow::{anyhow, Result}; use chrono::offset::Local; use nom::character::complete::{none_of, space0, space1}; use nom::{alt, many1, map, named, recognize, tag, tuple}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::fs; use std...
code_fim
hard
{ "lang": "rust", "repo": "takagiy/senklot", "path": "/src/state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for domain in self.domain_map.keys() { let lock_state = self.domanin_is_locked(domain); if lock_state != hosts.is_locked(domain) { state_is_changed = true; hosts.write_state(domain, lock_state); } ...
code_fim
hard
{ "lang": "rust", "repo": "takagiy/senklot", "path": "/src/state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Error)] pub enum StateTransitionError { #[error("Wrong precondition for this action; found state '{:?}'", _0)] WrongPrecondition(StateName), } impl<T> State<T> { /// Returns a reference to the held internals, or None if we're in a /// non-AVAILABLE state. pub fn get_in...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/identity/lib/storage_manager/src/state.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/identity/lib/storage_manager/src/state.rs // Copyright 2022 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use thiserror::Error; #[derive(Debug, PartialEq, Eq)] /// A ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/identity/lib/storage_manager/src/state.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> // AVAILABLE --lock--> LOCKED let mut state = State::Available { internals: 123 }; assert_matches!(state.try_lock(), Ok(123)); // state has changed assert_eq!(state, State::Locked); } #[test] fn test_try_lock_from_locked() { // LOCKED --lock--> ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/identity/lib/storage_manager/src/state.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sonygod/rust-project-euler path: /euler73/src/main.rs fn main() { // version 0.1 /* let mut count = 0; let mut v: Vec<(usize, usize)> = vec![]; for d in 2..=1200 { for n in 1..d { if 2 * n < d && d < 3 * n { let g = num::integer::gcd(n, d);...
code_fim
hard
{ "lang": "rust", "repo": "sonygod/rust-project-euler", "path": "/euler73/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match ((a, b), (a & 1, b & 1)) { ((x, y), _) if x == y => y, ((0, x), _) | ((x, 0), _) => x, ((x, y), (0, 1)) | ((y, x), (1, 0)) => gcd2(x >> 1, y), ((x, y), (0, 0)) => gcd2(x >> 1, y >> 1) << 1, ((x, y), (1, 1)) ...
code_fim
hard
{ "lang": "rust", "repo": "sonygod/rust-project-euler", "path": "/euler73/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //Other keys #[serde(with = "VirtualKeyCodeDef")] pub go_back: VirtualKeyCode, #[serde(with = "VirtualKeyCodeDef")] pub wait_turn: VirtualKeyCode, #[serde(with = "VirtualKeyCodeDef")] pub select: VirtualKeyCode, } impl Default for KeyBinds { fn default() -> Self { S...
code_fim
hard
{ "lang": "rust", "repo": "Zij-IT/Roguelike", "path": "/src/raws/config/config_structs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Zij-IT/Roguelike path: /src/raws/config/config_structs.rs use crate::gui::settings::visual; use rltk::VirtualKeyCode; use serde::Deserialize; use serde::Serialize; //Helping VirtualKeyCode #[derive(Serialize, Deserialize)] #[serde(remote = "VirtualKeyCode")] enum VirtualKeyCodeDef { Key1, ...
code_fim
hard
{ "lang": "rust", "repo": "Zij-IT/Roguelike", "path": "/src/raws/config/config_structs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //Item related grab_item: VirtualKeyCode::G, drop_item: VirtualKeyCode::D, remove_item: VirtualKeyCode::R, open_inventory: VirtualKeyCode::I, //Other go_back: VirtualKeyCode::Escape, wait_turn: VirtualKeyCode:...
code_fim
hard
{ "lang": "rust", "repo": "Zij-IT/Roguelike", "path": "/src/raws/config/config_structs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jlgerber/packybara-rest path: /src/crud/mod.rs pub mod distributions; pub mod levels; pub mod packages; pub mod<|fim_suffix|>ins; pub mod pkgcoords; pub mod withs; pub mod versionpin_withs;<|fim_middle|> packages_xml; pub mod platforms; pub mod roles; pub mod root; pub mod sites; pub mod version...
code_fim
medium
{ "lang": "rust", "repo": "jlgerber/packybara-rest", "path": "/src/crud/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ins; pub mod pkgcoords; pub mod withs; pub mod versionpin_withs;<|fim_prefix|>// repo: jlgerber/packybara-rest path: /src/crud/mod.rs pub mod distributions; pub mod levels; pub mod packages; pub mod<|fim_middle|> packages_xml; pub mod platforms; pub mod roles; pub mod root; pub mod sites; pub mod version...
code_fim
medium
{ "lang": "rust", "repo": "jlgerber/packybara-rest", "path": "/src/crud/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>println!("{}", serde_json::to_string(&meg).unwrap()); let client_future = clint.connect(&address, &handle).and_then(|_| Ok(())); core.run(client_future).unwrap(); } }<|fim_prefix|>// repo: maxtnuk/IGRUS_BOOK path: /tcp_test/src/act/client.rs use tokio_proto::TcpClient; use tokio_core:...
code_fim
hard
{ "lang": "rust", "repo": "maxtnuk/IGRUS_BOOK", "path": "/tcp_test/src/act/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maxtnuk/IGRUS_BOOK path: /tcp_test/src/act/client.rs use tokio_proto::TcpClient; use tokio_core::reactor::Core; use super::setting::proto::LineProto; use super::setting::service::{Message, State}; use std::net::SocketAddr; use futures::Fu<|fim_suffix|>println!("{}", serde_json::to_string(&meg).u...
code_fim
hard
{ "lang": "rust", "repo": "maxtnuk/IGRUS_BOOK", "path": "/tcp_test/src/act/client.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // &Self : type // &self : actual data (internally) // this function checks two values and returns a bool value pub fn is_smaller(&mut self, compare_to: i64) -> bool { // raise call count by 1 // if a variable is assigned this struct, // it must be mutable self.call_count += 1; // co...
code_fim
hard
{ "lang": "rust", "repo": "516M/Learning-rust", "path": "/src/structs/rand_info.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 516M/Learning-rust path: /src/structs/rand_info.rs // RandomInfo struct, used in main.rs // This is like OOP's abstract methods // Create a trait (polymorphism) pub trait SomeTrait { // what should be implemented if a struct // wants to utilize a trait // &self: actual data (internally) //...
code_fim
medium
{ "lang": "rust", "repo": "516M/Learning-rust", "path": "/src/structs/rand_info.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// use impl to create the functions/implement the structure impl RandomInfo { //"pub" to make it visible // -> RandomInfo: return a randominfo struct // but we can also use Self, to return the type of the implementation pub fn new(param_a: bool) -> Self { //RandomInfo { // utilize the Self keyword ...
code_fim
hard
{ "lang": "rust", "repo": "516M/Learning-rust", "path": "/src/structs/rand_info.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vaibhavantil2/third-party-api-clients path: /slack/src/calls.rs use anyhow::Result; use crate::Client; pub struct Calls { pub client: Client, } impl Calls { #[doc(hidden)] pub fn new(client: Client) -> Self { Calls { client } } /** * This function performs a ...
code_fim
hard
{ "lang": "rust", "repo": "vaibhavantil2/third-party-api-clients", "path": "/slack/src/calls.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.client.get(&url, None).await } /** * This function performs a `POST` to the `/calls.update` endpoint. * * Updates information about a Call. * * FROM: <https://api.slack.com/methods/calls.update> * * **Parameters:** * * * `token: &str` -- A...
code_fim
hard
{ "lang": "rust", "repo": "vaibhavantil2/third-party-api-clients", "path": "/slack/src/calls.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /** * This function performs a `POST` to the `/calls.update` endpoint. * * Updates information about a Call. * * FROM: <https://api.slack.com/methods/calls.update> * * **Parameters:** * * * `token: &str` -- Authentication token. Requires scope: `calls:write...
code_fim
hard
{ "lang": "rust", "repo": "vaibhavantil2/third-party-api-clients", "path": "/slack/src/calls.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sbnair/typestate-post path: /typestate-rust/src/repair_order/complex_state.rs use super::typestate::RepairOrder; type EndStates = OneOf4< RepairOrder<Finished>, RepairOrder<AprilFools>, RepairOrder<Garbage>, RepairOrder<Krangled>, >; type RepairOrderResult<T1, T2> = Result<Repai...
code_fim
hard
{ "lang": "rust", "repo": "sbnair/typestate-post", "path": "/typestate-rust/src/repair_order/complex_state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl RepairOrder<HighPriority> { fn enqueue(self) -> RepairOrder<WaitingForWorker> { self.with_state(WaitingForWorker) } } impl RepairOrder<Invalid> { fn recover(self) -> RepairOrderResult<Recovered, Krangled> { if self.check() { Ok(self.with_state(Recovered)) ...
code_fim
hard
{ "lang": "rust", "repo": "sbnair/typestate-post", "path": "/typestate-rust/src/repair_order/complex_state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn certificate_query(reader: &mut Reader) -> ParseResult<'static, QueryValue> { try_literal("certificate", reader)?; let space0 = one_or_more_spaces(reader)?; let field = certificate_field(reader)?; Ok(QueryValue::Certificate { space0, attribute_name: field, }) } fn ce...
code_fim
hard
{ "lang": "rust", "repo": "Orange-OpenSource/hurl", "path": "/packages/hurl_core/src/parser/query.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Orange-OpenSource/hurl path: /packages/hurl_core/src/parser/query.rs /* * Hurl (https://hurl.dev) * Copyright (C) 2023 Orange * * 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 th...
code_fim
hard
{ "lang": "rust", "repo": "Orange-OpenSource/hurl", "path": "/packages/hurl_core/src/parser/query.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn bytes_query(reader: &mut Reader) -> ParseResult<'static, QueryValue> { try_literal("bytes", reader)?; Ok(QueryValue::Bytes) } fn sha256_query(reader: &mut Reader) -> ParseResult<'static, QueryValue> { try_literal("sha256", reader)?; Ok(QueryValue::Sha256) } fn md5_query(reader: &mut R...
code_fim
hard
{ "lang": "rust", "repo": "Orange-OpenSource/hurl", "path": "/packages/hurl_core/src/parser/query.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn serialize_operation_crate_operation_put_account_sending_attributes( input: &crate::input::PutAccountSendingAttributesInput, ) -> Result<smithy_http::body::SdkBody, smithy_types::Error> { let mut out = String::new(); let mut object = smithy_json::serialize::JsonObjectWriter::new(&mut out...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/sesv2/src/operation_ser.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/sesv2/src/operation_ser.rs t out); crate::json_ser::serialize_structure_crate_input_create_configuration_set_input( &mut object, input, ); object.finish(); Ok(smithy_http::body::SdkBody::from(out)) } pub fn serialize_operation_crate...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/sesv2/src/operation_ser.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Split texts. Takes an array of strings as input and returns an array of the same length of `Split` objects. /// Each split has the properties /// * .text, the text in this `Split`. /// * .parts, the `Split`s contained in this `Split` (e. g. tokens in a sentence). /// unless...
code_fim
hard
{ "lang": "rust", "repo": "kornelski/nnsplit", "path": "/bindings/javascript/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kornelski/nnsplit path: /bindings/javascript/src/lib.rs mod tractjs_backend; mod utils; use js_sys::Array; use tractjs_backend::TractJSBackend; use wasm_bindgen::prelude::*; use nnsplit as core; #[cfg(feature = "wee_alloc")] #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::W...
code_fim
hard
{ "lang": "rust", "repo": "kornelski/nnsplit", "path": "/bindings/javascript/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let day: u32 = args[1].parse::<u32>().expect("Could not parse day selection"); let remaining = &args[2..]; runners::run_day(day, remaining); Ok(()) }<|fim_prefix|>// repo: BinaryMuse/advent-of-code-2019 path: /rust/src/main.rs mod runners; fn main() -> Result<(), std::io::Error> { l...
code_fim
medium
{ "lang": "rust", "repo": "BinaryMuse/advent-of-code-2019", "path": "/rust/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BinaryMuse/advent-of-code-2019 path: /rust/src/main.rs mod runners; fn main() -> Result<(), std::io::Error> { <|fim_suffix|> let day: u32 = args[1].parse::<u32>().expect("Could not parse day selection"); let remaining = &args[2..]; runners::run_day(day, remaining); Ok(()) }<|fim...
code_fim
medium
{ "lang": "rust", "repo": "BinaryMuse/advent-of-code-2019", "path": "/rust/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if args.len() < 2 { eprintln!("Usage: {} <day_num> [args...]", args[0]); std::process::exit(1); } let day: u32 = args[1].parse::<u32>().expect("Could not parse day selection"); let remaining = &args[2..]; runners::run_day(day, remaining); Ok(()) }<|fim_prefix|>// ...
code_fim
easy
{ "lang": "rust", "repo": "BinaryMuse/advent-of-code-2019", "path": "/rust/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MichaelHe1125/rust-leetcode path: /src/p0067_add_binary.rs // 67. Add Binary // Easy // Given two binary strings, return their sum (also a binary string). // The input strings are both non-empty and contains only characters 1 or 0. // Example 1: <|fim_suffix|>use std::char::from_digit; impl ...
code_fim
medium
{ "lang": "rust", "repo": "MichaelHe1125/rust-leetcode", "path": "/src/p0067_add_binary.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut tag = 0; let mut result = String::new(); while !(part_one.is_empty() && part_two.is_empty()) { let mut sum = part_one.pop().map_or(0, |ch| ch.to_digit(10).unwrap()) + part_two.pop().map_or(0, |ch| ch.to_digit(10).unwrap()) + tag;...
code_fim
hard
{ "lang": "rust", "repo": "MichaelHe1125/rust-leetcode", "path": "/src/p0067_add_binary.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Solution {} use std::char::from_digit; impl Solution { pub fn add_binary(a: String, b: String) -> String { let mut part_one: Vec<char> = a.chars().collect(); let mut part_two: Vec<char> = b.chars().collect(); let mut tag = 0; let mut result = String::new();...
code_fim
medium
{ "lang": "rust", "repo": "MichaelHe1125/rust-leetcode", "path": "/src/p0067_add_binary.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("New Game Rune"); } fn to_string(&self) -> String { serde_json::to_string(self).unwrap().replace("{", "{\"rune_type\":\"new_game\"") } } #[derive(Serialize, Deserialize, Debug, Clone, Copy)] pub struct NewController { is_me: bool, id: usize, color: TileSt...
code_fim
hard
{ "lang": "rust", "repo": "TuckerBMorgan/GoBoom", "path": "/examples/client_lib/client_runes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TuckerBMorgan/GoBoom path: /examples/client_lib/client_runes.rs use serde::{Serialize, Deserialize}; use GoBooM::*; use super::*; pub trait Rune : Send { fn execute(&self, client_state: &mut ClientGameState); fn to_string(&self) -> String; } #[derive(Serialize, Deserialize, Debug, Clon...
code_fim
hard
{ "lang": "rust", "repo": "TuckerBMorgan/GoBoom", "path": "/examples/client_lib/client_runes.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn execute(&self, _: &mut ClientGameState) { println!("New Game Rune"); } fn to_string(&self) -> String { serde_json::to_string(self).unwrap().replace("{", "{\"rune_type\":\"new_game\"") } } #[derive(Serialize, Deserialize, Debug, Clone, Copy)] pub struct NewController { ...
code_fim
hard
{ "lang": "rust", "repo": "TuckerBMorgan/GoBoom", "path": "/examples/client_lib/client_runes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut answer = 0; for term in number_vec.iter() { match *term { Integer(x) => answer += x, _ => fail!("Unexpected argument!") } } Ok(Number(Integer(answer))) } pub fn mul(terms: &Vec<BasicType>) -> Result<BasicType, StrBuf> { let mut numbe...
code_fim
hard
{ "lang": "rust", "repo": "libfud/risp", "path": "/src/interp/eval/eval.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match operator { Add => add(&operands), Mul => mul(&operands), Define => def(&operands, environment), _ => Err("idgi yet".to_strbuf()) } } pub fn add(terms: &Vec<BasicType>) -> Result<BasicType, StrBuf> { let mut number_vec: Vec<NumericType> = Vec::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "libfud/risp", "path": "/src/interp/eval/eval.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: libfud/risp path: /src/interp/eval/eval.rs extern crate collections; use self::collections::HashMap; use super::super::{SExpr, Cons, Nil, Data, DataType, car, cdr}; use super::super::{Operator, Literal, Variable}; use super::super::{Environment, lookup}; use super::super::basictype::BasicType;...
code_fim
hard
{ "lang": "rust", "repo": "libfud/risp", "path": "/src/interp/eval/eval.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lpc55/lpc55-pac path: /src/inputmux/dma0_itrig_ena.rs #[doc = "Register `DMA0_ITRIG_ENA` reader"] pub struct R(crate::R<DMA0_ITRIG_ENA_SPEC>); impl core::ops::Deref for R { type Target = crate::R<DMA0_ITRIG_ENA_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self...
code_fim
hard
{ "lang": "rust", "repo": "lpc55/lpc55-pac", "path": "/src/inputmux/dma0_itrig_ena.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> W(writer) } } #[doc = "Field `ITRIG_ENA` reader - Controls the 22 trigger inputs of DMA0. If bit i is '1' the DMA trigger input #i is enabled."] pub struct ITRIG_ENA_R(crate::FieldReader<u32, u32>); impl ITRIG_ENA_R { #[inline(always)] pub(crate) fn new(bits: u32) -> Self { ITR...
code_fim
hard
{ "lang": "rust", "repo": "lpc55/lpc55-pac", "path": "/src/inputmux/dma0_itrig_ena.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> impl Default for Access{ fn default()->Self{ Access::MutValue } } impl Parse for Access { fn parse(input: ParseStream) -> Result<Self,syn::Error> { if input.peek_parse(Token![ref]).is_some() { if input.peek_parse(Token![move]).is_some() { Ok(Access...
code_fim
hard
{ "lang": "rust", "repo": "RalfJung/structural_crates", "path": "/structural_derive/src/field_access.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RalfJung/structural_crates path: /structural_derive/src/field_access.rs use crate::parse_utils::ParseBufferExt; #[allow(unused_imports)] use core_extensions::SelfOps; use proc_macro2::{ TokenStream as TokenStream2, Span, }; use quote::ToTokens; use syn::{ parse::{Parse,ParseStrea...
code_fim
hard
{ "lang": "rust", "repo": "RalfJung/structural_crates", "path": "/structural_derive/src/field_access.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stkfd/tmi-rs path: /src/event/mod.rs //! Data types and parsing logic for events that can be received //! from the twitch servers. use std::borrow::Borrow; use std::convert::{From, Into, TryFrom}; use std::fmt::Debug; use std::sync::Arc; use derive_more::From; use fnv::FnvHashMap; pub use inn...
code_fim
hard
{ "lang": "rust", "repo": "stkfd/tmi-rs", "path": "/src/event/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Methods common to all EventContent variants impl<T, Inner> EventData<T, Inner> where T: StringRef, Inner: Debug + Clone + Eq, Event<T>: From<EventData<T, Inner>>, { /// Get the sender of the message pub fn sender(&self) -> &Option<T> { &self.sender } /// Get the da...
code_fim
hard
{ "lang": "rust", "repo": "stkfd/tmi-rs", "path": "/src/event/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sender = msg.sender().copied(); Ok(match msg.command { "PRIVMSG" => { check_parameter_count(2, &msg)?; EventData { sender, event: PrivMsgEvent::from(ChannelMessageEvent::new( *ms...
code_fim
hard
{ "lang": "rust", "repo": "stkfd/tmi-rs", "path": "/src/event/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danhper/diem path: /language/tools/move-cli/src/base/commands/check.rs // Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use std::collections::BTreeMap; <|fim_suffix|>/// Type-check the user modules in `files` and the dependencies in `interface_files` pub fn ch...
code_fim
medium
{ "lang": "rust", "repo": "danhper/diem", "path": "/language/tools/move-cli/src/base/commands/check.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Type-check the user modules in `files` and the dependencies in `interface_files` pub fn check( interface_files: &[String], sources_shadow_deps: bool, files: &[String], named_addresses: BTreeMap<String, AddressBytes>, verbose: bool, ) -> Result<()> { if verbose { println...
code_fim
medium
{ "lang": "rust", "repo": "danhper/diem", "path": "/language/tools/move-cli/src/base/commands/check.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if pstr_s[n .. n + m_len] == s[n1 .. n1 + m_len] { if s_len <= pstr_len { pdl.push(Addr::Con(Constant::EmptyList)); pdl.push(Addr::PStrLocation(h, n + m_len))...
code_fim
hard
{ "lang": "rust", "repo": "srenatus/scryer-prolog", "path": "/src/prolog/machine/machine_state_impl.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: srenatus/scryer-prolog path: /src/prolog/machine/machine_state_impl.rs erms: Vec<Number> = Vec::with_capacity(64); for heap_val in self.post_order_iter(a) { match heap_val { HeapCellValue::NamedStr(2, name, _) => { let a2 = interms.pop().u...
code_fim
hard
{ "lang": "rust", "repo": "srenatus/scryer-prolog", "path": "/src/prolog/machine/machine_state_impl.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: srenatus/scryer-prolog path: /src/prolog/machine/machine_state_impl.rs _ => 0, }; match offset { 0 => self.fail = true, o => self.p += o, }; } &IndexingInstruction::Swi...
code_fim
hard
{ "lang": "rust", "repo": "srenatus/scryer-prolog", "path": "/src/prolog/machine/machine_state_impl.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sidkshatriya/rd path: /src/trace/trace_reader_rocksdb.rs use super::{ trace_reader::{resolve_trace_name, TraceReaderBackend}, trace_stream::{substreams_data, Substream, TraceStream, SUBSTREAM_COUNT}, }; use crate::{trace::lexical_key::LexicalKey128, util::get_num_cpus}; use capnp::{messa...
code_fim
hard
{ "lang": "rust", "repo": "sidkshatriya/rd", "path": "/src/trace/trace_reader_rocksdb.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn at_end(&self, substream: Substream) -> bool { self.iter(substream).next().is_none() } fn discard_state(&mut self, substream: Substream) { self.saved_states[substream as usize] = None; } fn save_state(&mut self, substream: Substream) { self.saved_states[subs...
code_fim
hard
{ "lang": "rust", "repo": "sidkshatriya/rd", "path": "/src/trace/trace_reader_rocksdb.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn read_data_exact( &mut self, substream: Substream, size: usize, ) -> Result<Vec<u8>, Box<dyn std::error::Error>> { let (key, value) = self.iter(substream).next().unwrap(); self.current_keys[substream as usize] = Some(LexicalKey128::from(&*key)); as...
code_fim
hard
{ "lang": "rust", "repo": "sidkshatriya/rd", "path": "/src/trace/trace_reader_rocksdb.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn new() -> Universe { let width = 256; let height = 256; let size = (width * height) as usize; let mut cells = FixedBitSet::with_capacity(size); for i in 0..size { cells.set(i, i % 2 == 0 || i % 7 == 0); } Universe { ...
code_fim
hard
{ "lang": "rust", "repo": "moritzschramm/game-of-life-wasm", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let sw = self.get_index(south, west); count += self.cells[sw] as u8; let s = self.get_index(south, column); count += self.cells[s] as u8; let se = self.get_index(south, east); count += self.cells[se] as u8; count } pub fn tick(&mut self)...
code_fim
hard
{ "lang": "rust", "repo": "moritzschramm/game-of-life-wasm", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: moritzschramm/game-of-life-wasm path: /src/lib.rs mod utils; extern crate fixedbitset; use wasm_bindgen::prelude::*; use fixedbitset::FixedBitSet; // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global // allocator. #[cfg(feature = "wee_alloc")] #[global_allocator] static ...
code_fim
hard
{ "lang": "rust", "repo": "moritzschramm/game-of-life-wasm", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>_ref()) { Ok(re) => dfas.push(Dfa::from_nfa(&Nfa::from_re(&re), id as u32).minimize()), Err(err) => return Err((id, err)), } } let dfa = Dfa::merge(&dfas); let ec = ec_of_dfas(&[&dfa]); Ok((dfa, ec)) }<|fim_prefix|>// repo: merge34/re2dfa path: /src/lib.rs pub mod compress; pub mo...
code_fim
hard
{ "lang": "rust", "repo": "merge34/re2dfa", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }