text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>pub struct PingBuilder<'a> { payload: &'a [u8], } impl<'a> PingBuilder<'a> { pub fn new(payload: &'a [u8]) -> PingBuilder<'a> { PingBuilder { payload: payload } } } impl<'a> IcmpProtocol for PingBuilder<'a> { fn icmp_type(&self) -> IcmpType { IcmpTypes::EchoRequest } ...
code_fim
hard
{ "lang": "rust", "repo": "geezer-workshop/librips", "path": "/src/icmp/icmp_tx.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geezer-workshop/librips path: /src/icmp/icmp_tx.rs use {Protocol, TxResult}; use ipv4::Ipv4Protocol; #[cfg(not(all(test, feature = "unit-tests")))] use ipv4::Ipv4Tx; use pnet::packet::MutablePacket; use pnet::packet::icmp::{IcmpCode, IcmpPacket, IcmpType, MutableIcmpPacket, checksum, IcmpTypes}...
code_fim
hard
{ "lang": "rust", "repo": "geezer-workshop/librips", "path": "/src/icmp/icmp_tx.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> IcmpTypes::EchoRequest } fn icmp_code(&self) -> IcmpCode { IcmpCodes::NoCode } } impl<'a> Protocol for PingBuilder<'a> { fn len(&self) -> usize { EchoRequestPacket::minimum_packet_size() - IcmpPacket::minimum_packet_size() + self.payload.len() } f...
code_fim
hard
{ "lang": "rust", "repo": "geezer-workshop/librips", "path": "/src/icmp/icmp_tx.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ubnt-intrepid/rye path: /xtask/src/main.rs mod coverage; mod doc; mod hook; mod lint; mod shell; mod test; use crate::shell::Shell; use pico_args::Arguments; fn main() -> anyhow::Result<()> { let show_help = || { eprintln!( "\ cargo-xtask Free style automation tool Usa...
code_fim
hard
{ "lang": "rust", "repo": "ubnt-intrepid/rye", "path": "/xtask/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let subcommand = args.subcommand().map_err(|err| { show_help(); err })?; match subcommand.as_deref() { Some("test") => { let sh = Shell::new(); crate::test::do_test(&sh) } Some("doc") => { let serve_addr = if args.con...
code_fim
hard
{ "lang": "rust", "repo": "ubnt-intrepid/rye", "path": "/xtask/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: olanod/webworker-rs path: /src/lib.rs use futures::{ channel::mpsc::{channel, Receiver, Sender}, stream::Stream, }; pub use futures::stream::StreamExt; #[cfg(target_arch = "wasm32")] mod rt { use super::*; use wasm_bindgen::{prelude::*, JsCast}; use web_sys::{MessageEvent, ...
code_fim
hard
{ "lang": "rust", "repo": "olanod/webworker-rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn spawn<T>(_script_url: &str) -> Result<(Sender<&[u8]>, Receiver<T>), ()> where T: for<'de> serde::Deserialize<'de> + 'static, { todo!() } } pub struct Worker<T> { messages: Receiver<T>, } impl<T> Worker<T> where T: for<'de> serde::Deserialize<'de> + '...
code_fim
hard
{ "lang": "rust", "repo": "olanod/webworker-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok((tx, rx)) } } #[cfg(not(target_arch = "wasm32"))] mod rt { use super::*; //use deno_core::{error::AnyError, JsRuntime}; pub(crate) fn spawn<T>(_script_url: &str) -> Result<(Sender<&[u8]>, Receiver<T>), ()> where T: for<'de> serde::Deserialize<'de> + 'static, { ...
code_fim
hard
{ "lang": "rust", "repo": "olanod/webworker-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn current_query(&self) -> Option<String> { let guard = self .query .read() .expect("failed to unlock query for current_query"); match &*guard { QueryState::Active { query, .. } => Some(query.clone()), QueryState::None =>...
code_fim
hard
{ "lang": "rust", "repo": "parampavar/cube.js", "path": "/rust/cubesql/cubesql/src/sql/session.rs", "mode": "spm", "license": "Cube", "source": "the-stack-v2" }
<|fim_prefix|>// repo: parampavar/cube.js path: /rust/cubesql/cubesql/src/sql/session.rs use datafusion::scalar::ScalarValue; use log::trace; use rand::Rng; use std::{ collections::HashMap, sync::{Arc, RwLock as RwLockSync}, }; use tokio_util::sync::CancellationToken; use crate::{ sql::{ database_...
code_fim
hard
{ "lang": "rust", "repo": "parampavar/cube.js", "path": "/rust/cubesql/cubesql/src/sql/session.rs", "mode": "psm", "license": "Cube", "source": "the-stack-v2" }
<|fim_suffix|> let emit_options: ast::EmitOptions = compiler_options.into(); let mut emit_map = HashMap::new(); for (specifier, source) in args.sources { let media_type = MediaType::from(&specifier); let parsed_module = ast::parse(&specifier, &source, &media_type)?; let (source, maybe_source_map) = pa...
code_fim
hard
{ "lang": "rust", "repo": "getspooky/deno", "path": "/cli/ops/runtime_compiler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: getspooky/deno path: /cli/ops/runtime_compiler.rs // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. use crate::ast; use crate::colors; use crate::media_type::MediaType; use crate::permissions::Permissions; use crate::tsc::runtime_bundle; use crate::tsc::runtime_compile;...
code_fim
hard
{ "lang": "rust", "repo": "getspooky/deno", "path": "/cli/ops/runtime_compiler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns a unit vector *from* the point to the light source, and a /// length for the distance to the light source (which may be infinite). /// /// If the length is not infinite, the following should hold: /// /// ```rust,ignore /// let (dir, dist) = light.direction_from(po...
code_fim
hard
{ "lang": "rust", "repo": "remexre/csci5607", "path": "/asgn2/src/light/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: remexre/csci5607 path: /asgn2/src/light/mod.rs //! Lights. mod directional; mod point; mod spot; use std::fmt::Debug; use cgmath::Vector3; use image::Rgb; pub use light::directional::Directional; pub use light::point::Point; pub use light::spot::Spot; /// Any light defined in this crate. //...
code_fim
hard
{ "lang": "rust", "repo": "remexre/csci5607", "path": "/asgn2/src/light/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn intensity_at(&self, point: Vector3<f32>) -> f32 { match *self { DynamicLight::Directional(ref d) => d.intensity_at(point), DynamicLight::Point(ref p) => p.intensity_at(point), DynamicLight::Spot(ref s) => s.intensity_at(point), } } } /// A tr...
code_fim
hard
{ "lang": "rust", "repo": "remexre/csci5607", "path": "/asgn2/src/light/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: clintjhill/octocopycat path: /src/main.rs extern crate serialize; use std::sync::mpsc::{Sender, Receiver}; use std::sync::mpsc; use serialize::json::Json; mod git; mod env; fn main() { <|fim_suffix|> for threads in repositories.iter() { println!("{}", rx.recv().ok().expect("No message rece...
code_fim
hard
{ "lang": "rust", "repo": "clintjhill/octocopycat", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod git; mod env; fn main() { let env_config: env::Environment = env::get("env.toml"); let repositories: Vec<Json> = git::repos(env_config.clone()); let mut messages: Vec<String> = Vec::new(); let (tx, rx): (Sender<String>, Receiver<String>) = mpsc::channel(); for location in repositories.iter() {...
code_fim
medium
{ "lang": "rust", "repo": "clintjhill/octocopycat", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[tracable_parser] #[packrat_parser] pub(crate) fn removal_timing_check(s: Span) -> IResult<Span, RemovalTimingCheck> { let (s, a) = keyword("$removal")(s)?; let (s, b) = paren(tuple(( referecne_event, symbol(","), data_event, symbol(","), timing_check_limit...
code_fim
hard
{ "lang": "rust", "repo": "dalance/sv-parser", "path": "/sv-parser-parser/src/specify_section/system_timing_check_commands.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[tracable_parser] #[packrat_parser] pub(crate) fn fullskew_timing_check(s: Span) -> IResult<Span, FullskewTimingCheck> { let (s, a) = keyword("$fullskew")(s)?; let (s, b) = paren(tuple(( referecne_event, symbol(","), data_event, symbol(","), timing_check_li...
code_fim
hard
{ "lang": "rust", "repo": "dalance/sv-parser", "path": "/sv-parser-parser/src/specify_section/system_timing_check_commands.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dalance/sv-parser path: /sv-parser-parser/src/specify_section/system_timing_check_commands.rs use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] #[packrat_parser] pub(crate) fn system_timing_check(s: Span) -> IResult<Span, SystemTi...
code_fim
hard
{ "lang": "rust", "repo": "dalance/sv-parser", "path": "/sv-parser-parser/src/specify_section/system_timing_check_commands.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: unlink2/deq path: /lib/tests/feature_serde.rs #[cfg(feature = "serde")] mod tests { extern crate deq; extern crate serde_json; use self::deq::{Revertable, Transaction}; <|fim_suffix|> let serialized = serde_json::to_string(&test).unwrap(); #[cfg(not(feature = "serde_...
code_fim
medium
{ "lang": "rust", "repo": "unlink2/deq", "path": "/lib/tests/feature_serde.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let serialized = serde_json::to_string(&test).unwrap(); #[cfg(not(feature = "serde_skip_history"))] assert_eq!(serialized, "{\"current\":300,\"history\":[100]}"); #[cfg(feature = "serde_skip_history")] assert_eq!(serialized, "{\"current\":300}"); } }<|fim_pref...
code_fim
medium
{ "lang": "rust", "repo": "unlink2/deq", "path": "/lib/tests/feature_serde.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> | | \\ V /| \\__ \\ | |_) | | __/ (__| | | | (_| | |_ \n")).unwrap(); (write!(t, "|_|_| |_|\\_/ |_|___/_|_.__/|_|\\___|\\___|_| |_|\\__,_|\\__|\n\n" )).unwrap(); t.reset().unwrap(); }<|fim_prefix|>// repo: daniel-e/tcpip path: /icmp_chat/rust/src/logo.rs extern crate term; use std::io::prelud...
code_fim
medium
{ "lang": "rust", "repo": "daniel-e/tcpip", "path": "/icmp_chat/rust/src/logo.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: daniel-e/tcpip path: /icmp_chat/rust/src/logo.rs extern crate term; use std::io::prelude::*; // font: doom // http://www.network-science.de/ascii/ pub fn print_logo() { let mut t = term::stdout().unwrap(); t.fg(term::color::GREEN).u<|fim_suffix|> | | \\ V /| \\__ \\ | |_) | | __/ (__|...
code_fim
hard
{ "lang": "rust", "repo": "daniel-e/tcpip", "path": "/icmp_chat/rust/src/logo.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let TsEmptyExternalModuleDeclarationBodyFields { semicolon_token } = self.as_fields(); semicolon_token.format(formatter) } }<|fim_prefix|>// repo: Tembocs/rome path: /crates/rome_js_formatter/src/ts/auxiliary/empty_external_module_declaration_body.rs use crate::formatter_traits::Forma...
code_fim
medium
{ "lang": "rust", "repo": "Tembocs/rome", "path": "/crates/rome_js_formatter/src/ts/auxiliary/empty_external_module_declaration_body.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tembocs/rome path: /crates/rome_js_formatter/src/ts/auxiliary/empty_external_module_declaration_body.rs use crate::formatter_traits::FormatTokenAndNode; use crate::{FormatElement, FormatResult, Formatter, ToFormatElement}; use rome_js_syntax::TsEmptyExternalModuleDeclarationBody; use rome_js_syn...
code_fim
medium
{ "lang": "rust", "repo": "Tembocs/rome", "path": "/crates/rome_js_formatter/src/ts/auxiliary/empty_external_module_declaration_body.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let proto_game_state = GameState::from(&game_state); *persistent_state = game_state; Ok(proto_game_state) } } fn new_game_state() -> Result<s::GameState, Error> { use s::*; let config = GameConfig::default(); let game_state = GameState::create_from(&config)?; ...
code_fim
hard
{ "lang": "rust", "repo": "geropl/roborally", "path": "/backend/src/service.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geropl/roborally path: /backend/src/service.rs use tonic::{ Request, Response, Status, Code }; use failure::Error; use std::sync::{ Arc, Mutex }; use crate::protocol::robo_rally_game_server::RoboRallyGame; use crate::protocol::{ StartGameRequest, StartGameResponse, GetGameStateRequest, GetGame...
code_fim
hard
{ "lang": "rust", "repo": "geropl/roborally", "path": "/backend/src/service.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set(&mut self, name: String, val: Object) -> Object { self.store.insert(name.clone(), val.clone()); val } }<|fim_prefix|>// repo: novoru/simia path: /src/env.rs use crate::object::{ Object }; use std::collections::HashMap; #[derive(Debug, Clone)] pub struct Env { stor...
code_fim
hard
{ "lang": "rust", "repo": "novoru/simia", "path": "/src/env.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: novoru/simia path: /src/env.rs use crate::object::{ Object }; use std::collections::HashMap; #[derive(Debug, Clone)] pub struct Env { store: HashMap<String, Object>, outer: Option<Box<Env>>, } impl Env { pub fn new_enclosed_env(outer: Box<Env>) -> Env { let mut env = Env::n...
code_fim
hard
{ "lang": "rust", "repo": "novoru/simia", "path": "/src/env.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Constructs a new Kubernetes client. /// /// The `context` specifies the Kubernetes context to load. If loading from the /// context fails, the in-cluster configuration is attempted. /// /// Returns the constructed client and the default namespace loaded from the /// configuration. pub async fn create_...
code_fim
medium
{ "lang": "rust", "repo": "nisarhassan12/materialize", "path": "/src/orchestrator-kubernetes/src/util.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nisarhassan12/materialize path: /src/orchestrator-kubernetes/src/util.rs // Copyright Materialize, Inc. and contributors. All rights reserved. // // Use of this software is governed by the Business Source License // included in the LICENSE file. // // As of the Change Date specified in that file...
code_fim
medium
{ "lang": "rust", "repo": "nisarhassan12/materialize", "path": "/src/orchestrator-kubernetes/src/util.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!("Hello from next bigger number"); assert_eq!(21, next_bigger_number(12)); assert_eq!(531, next_bigger_number(513)); assert_eq!(2071, next_bigger_number(2017)); assert_eq!(441, next_bigger_number(414)); assert_eq!(414, next_bigger_number(144)); assert_eq!(1234567908, ne...
code_fim
medium
{ "lang": "rust", "repo": "Stephen-J/codewars", "path": "/rust/4kyu/next_bigger_number_with_same_digits.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Stephen-J/codewars path: /rust/4kyu/next_bigger_number_with_same_digits.rs //https://www.codewars.com/kata/55983863da40caa2c900004e/train/rust fn next_bigger_number(n: i64) -> i64 { let mut nums : Vec<u8> = n.to_string().as_bytes().iter().map(|v| v - 48).collect::<Vec<u8>>(); let origi...
code_fim
medium
{ "lang": "rust", "repo": "Stephen-J/codewars", "path": "/rust/4kyu/next_bigger_number_with_same_digits.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: software-opal/metlink-cancellation-tweetbot path: /src/parser.rs n!("{}", BUS_FULL_CANCELLED_RE.as_str()); parse_tweet_str( &"Bus 17: Bua 17: 8:20pm Wellington Station to Kowhai Park is cancelled. Please check RTI for next service.", vec![Cancellation...
code_fim
hard
{ "lang": "rust", "repo": "software-opal/metlink-cancellation-tweetbot", "path": "/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> parse_tweet_str( &"Bus 160: Bus 160: 8:23am from Wainuiomata to Lower Hutt is reinstated.", vec![Cancellations::BusReinstated { route: "160".to_string(), origin: "Wainuiomata".to_string(), destination: ...
code_fim
hard
{ "lang": "rust", "repo": "software-opal/metlink-cancellation-tweetbot", "path": "/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: software-opal/metlink-cancellation-tweetbot path: /src/parser.rs n Stn".to_string(), raw_time: "5:10 pm".to_string(), tweet_time, time: convert_time_to_instant(tweet_time, 17, 10).unwrap() }], ); } ...
code_fim
hard
{ "lang": "rust", "repo": "software-opal/metlink-cancellation-tweetbot", "path": "/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> DayObject::Character( std::io::stdin() .bytes() .next() .expect("Can't read from stdin") .expect("Can't read a byte from stdin") as char, ) }<|fim_prefix|>// repo: DrSloth/Crabscript path: /src/c1/std_modules/io.rs use super::conversion::to_...
code_fim
hard
{ "lang": "rust", "repo": "DrSloth/Crabscript", "path": "/src/c1/std_modules/io.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> DayObject::None } pub fn readln(args: Args, _mgr: &Arc<ExecutionManager>) -> DayObject { if !args.is_empty() { eprintln!("read expected 0 argument(s) received: {}", args.len()); } let mut s = String::new(); std::io::stdin() .read_line(&mut s) .expect("Unable t...
code_fim
medium
{ "lang": "rust", "repo": "DrSloth/Crabscript", "path": "/src/c1/std_modules/io.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DrSloth/Crabscript path: /src/c1/std_modules/io.rs use super::conversion::to_string_inner; use crate::base::{Args, DayObject}; use crate::variables::ExecutionManager; use std::{io::Read, sync::Arc}; pub fn print(args: Args, _mgr: &Arc<ExecutionManager>) -> DayObject { for a in args { ...
code_fim
medium
{ "lang": "rust", "repo": "DrSloth/Crabscript", "path": "/src/c1/std_modules/io.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn from_str(s: &str) -> Result<Self, Self::Err> { let parts = s.split(")").collect::<Vec<&str>>(); if parts.len() != 2 { return Err(Error::ParseError); } Ok(Orbit { object: parts[1].to_owned(), around: parts[0].to_owned(), }) ...
code_fim
hard
{ "lang": "rust", "repo": "jgraef/aoc-2019", "path": "/src/day6.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jgraef/aoc-2019 path: /src/day6.rs use std::str::FromStr; use std::collections::HashMap; use std::rc::Rc; use aoc_runner_derive::{aoc, aoc_generator}; use failure::Fail; use crate::util; #[derive(Clone, Debug, Fail)] pub enum Error { #[fail(display = "Parse error")] ParseError, } #[...
code_fim
hard
{ "lang": "rust", "repo": "jgraef/aoc-2019", "path": "/src/day6.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// error: this function's return type contains a borrowed value, but there is no value for it to be borrowed from // fn dangle() -> &String { // let s = String::from("hello"); // &s // }<|fim_prefix|>// repo: ryoherisson/rust-programming path: /src/rust-programming-language/04_ownership/referenc...
code_fim
hard
{ "lang": "rust", "repo": "ryoherisson/rust-programming", "path": "/src/rust-programming-language/04_ownership/references_borrowing/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ryoherisson/rust-programming path: /src/rust-programming-language/04_ownership/references_borrowing/src/main.rs fn main() { let s1 = String::from("hello"); let len = calculate_length(&s1); println!("The length of '{}' is {}.", s1, len); // let s = String::from("hello"); let...
code_fim
medium
{ "lang": "rust", "repo": "ryoherisson/rust-programming", "path": "/src/rust-programming-language/04_ownership/references_borrowing/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn change(some_string: &mut String) { some_string.push_str(", world"); } // error: this function's return type contains a borrowed value, but there is no value for it to be borrowed from // fn dangle() -> &String { // let s = String::from("hello"); // &s // }<|fim_prefix|>// repo: ryoherisso...
code_fim
medium
{ "lang": "rust", "repo": "ryoherisson/rust-programming", "path": "/src/rust-programming-language/04_ownership/references_borrowing/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let a: Self::Opaque1 = (); let b: Self::Opaque2 = self; (a, b) } } fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/type-alias-impl-trait/associated-type-impl-trait-lifetime.rs //check-pass #![feature(impl_trait_in_assoc_type)] trait Trait { type Opaque...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/type-alias-impl-trait/associated-type-impl-trait-lifetime.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>} impl<'a> Trait for &'a () { type Opaque1 = impl Sized; type Opaque2 = impl Sized + 'a; fn constrain(self) -> (Self::Opaque1, Self::Opaque2) { let a: Self::Opaque1 = (); let b: Self::Opaque2 = self; (a, b) } } fn main() {}<|fim_prefix|>// repo: rust-lang/rust pa...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/type-alias-impl-trait/associated-type-impl-trait-lifetime.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/type-alias-impl-trait/associated-type-impl-trait-lifetime.rs //check-pass #![feature(impl_trait_in_assoc_type)] <|fim_suffix|>} impl<'a> Trait for &'a () { type Opaque1 = impl Sized; type Opaque2 = impl Sized + 'a; fn constrain(self) -> (Self::Opaque...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/type-alias-impl-trait/associated-type-impl-trait-lifetime.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jaw-sh/ruforo path: /src/bbcode/token.rs /// A single Token output by the tokenizer. #[derive(Debug, PartialEq, Clone)] pub enum Token<'a> { Null, Linebreak(&'a str), Tag(&'a str, &'a str, Option<&'a str>), TagClose(&'a str, &'a str), Text(&'a str), Url(&'a str), } impl<...
code_fim
hard
{ "lang": "rust", "repo": "jaw-sh/ruforo", "path": "/src/bbcode/token.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use super::Token; let inst = Token::Linebreak("\n\r"); assert_eq!(inst.as_raw(), "\n\r"); let inst = Token::Linebreak("\n\r"); assert_eq!(inst.as_raw(), "\n\r"); } #[test] fn reverse_tag() { use super::Token; let inst = Token::Tag("[f...
code_fim
hard
{ "lang": "rust", "repo": "jaw-sh/ruforo", "path": "/src/bbcode/token.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let inst = Token::Linebreak("\n\r"); assert_eq!(inst.as_raw(), "\n\r"); } #[test] fn reverse_tag() { use super::Token; let inst = Token::Tag("[foo]", "foo", None); assert_eq!(inst.as_raw(), "[foo]"); let inst = Token::Tag( "[url=ht...
code_fim
hard
{ "lang": "rust", "repo": "jaw-sh/ruforo", "path": "/src/bbcode/token.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use crate::reflect::acc::v2::map::make_map_simpler_accessor; pub use crate::reflect::acc::v2::repeated::make_vec_simpler_accessor; pub use crate::reflect::acc::v2::singular::make_message_field_accessor; pub use crate::reflect::acc::v2::singular::make_option_accessor; pub use crate::reflect::acc::v2::s...
code_fim
medium
{ "lang": "rust", "repo": "Tim-Zhang/rust-protobuf", "path": "/protobuf/src/reflect/rt/v2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tim-Zhang/rust-protobuf path: /protobuf/src/reflect/rt/v2.rs //! This module contains functions references for reflection in generated code. <|fim_suffix|>pub use crate::reflect::acc::v2::map::make_map_simpler_accessor; pub use crate::reflect::acc::v2::repeated::make_vec_simpler_accessor; pub u...
code_fim
medium
{ "lang": "rust", "repo": "Tim-Zhang/rust-protobuf", "path": "/protobuf/src/reflect/rt/v2.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yjhmelody/learn-rust path: /testing/tests/integration_test.rs extern crate testing; // 我们在顶部增加了 extern crate adder ,这在单元测试中是不需要的。这是因为每一个 // tests 目录中的测试文件都是完全独立的 crate,所以需要在每一个文件中导入库。 // 并不需要将 tests/integration_test.rs 中的任何代码标注为 #[cfg(test)] 。Cargo 对 tests // 文件夹特殊处理并只会在运行 cargo test 时编译这个目录中的...
code_fim
hard
{ "lang": "rust", "repo": "yjhmelody/learn-rust", "path": "/testing/tests/integration_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// 为了避免 common 出现在测试输出中,不同于创建 tests/common.rs,我们将创建 // tests/common/mod.rs。在第七章的 “模块文件系统规则” 部分,对于拥有子模块的模块文件使 // 用了 module_name/mod.rs 命名规范,虽然这里 common 并没有子模块,但是这样命名告诉 // Rust 不要将 common 看作一个集成测试文件。当将 setup 代码移动到 // tests/common/mod.rs 并去掉 tests/common.rs 文件之后,测试输出中将不会出现这一部 // 分。tests 目录中的子目录不会被作为单独的 crate...
code_fim
hard
{ "lang": "rust", "repo": "yjhmelody/learn-rust", "path": "/testing/tests/integration_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChaosStudyGroup/http-server path: /src/server/service/file_explorer.rs use anyhow::{Context, Result}; use chrono::prelude::*; use chrono::{DateTime, Local}; use handlebars::Handlebars; use http::response::Builder as HttpResponseBuilder; use http::StatusCode; use hyper::{Body, Request, Response};...
code_fim
hard
{ "lang": "rust", "repo": "ChaosStudyGroup/http-server", "path": "/src/server/service/file_explorer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let i = (bytes.log10() / 1024_f64.log10()).floor(); let value = bytes / 1024_f64.powf(i); format!("{:.2} {}", value, BYTE_SIZE_UNIT[i as usize]) } /// Formats a `SystemTime` into a YYYY/MM/DD HH:MM:SS time `String` fn format_system_date(system_time: SystemTime) -> Str...
code_fim
hard
{ "lang": "rust", "repo": "ChaosStudyGroup/http-server", "path": "/src/server/service/file_explorer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if path.ends_with('/') { return PathBuf::from_str(path[..path.len() - 1].to_string().as_str()) .context("Unable to buid path"); } PathBuf::from_str(path.as_str())? } else { PathBuf::from_str(req_path.as_str())? ...
code_fim
hard
{ "lang": "rust", "repo": "ChaosStudyGroup/http-server", "path": "/src/server/service/file_explorer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut res = Vec::with_capacity(board.size() * board.size()); for row in 0..board.size() { for col in 0..board.size() { match board[row][col] { Entry::Clue(_) => (), _ => res.push((row, col)), } } } res } pub fn fill...
code_fim
hard
{ "lang": "rust", "repo": "jakobht/sudoku", "path": "/src/solver.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn generate_order(board: &Board) -> Vec<(usize, usize)> { let mut res = Vec::with_capacity(board.size() * board.size()); for row in 0..board.size() { for col in 0..board.size() { match board[row][col] { Entry::Clue(_) => (), _ => res.push((row, c...
code_fim
hard
{ "lang": "rust", "repo": "jakobht/sudoku", "path": "/src/solver.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jakobht/sudoku path: /src/solver.rs extern crate test; use crate::board::{Board, Entry}; #[derive(Debug)] struct FilledCache { rows: Vec<bool>, cols: Vec<bool>, squares: Vec<bool>, } #[inline(always)] fn get<'a>(v: &'a mut Vec<bool>, i: usize, j: u8, length: usize) -> &'a mut bool...
code_fim
hard
{ "lang": "rust", "repo": "jakobht/sudoku", "path": "/src/solver.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(grid.positions[0].x, 2); assert_eq!(grid.positions[0].y, -1); assert_eq!(grid.positions[1].x, 2); assert_eq!(grid.positions[1].y, -1); } } fn main() -> Result<(), std::io::Error> { let args: Vec<String> = env::args().collect(); if args.len() < 2 { ...
code_fim
hard
{ "lang": "rust", "repo": "mrnugget/advent_of_code", "path": "/day10/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mrnugget/advent_of_code path: /day10/src/main.rs extern crate regex; use regex::Regex; use std::env; use std::fs::File; use std::io::prelude::*; use std::process; fn parse_input<'a, I>(lines: I) -> Vec<Position> where I: Iterator<Item = &'a str>, { let line_re: Regex = Regex::n...
code_fim
hard
{ "lang": "rust", "repo": "mrnugget/advent_of_code", "path": "/day10/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[aoc(day1, part2)] pub fn p2(input: &[u32]) -> u32 { let n = input.len(); for i in 0..n - 2 { for j in i + 1..n - 1 { for k in j + 1..n { let x = input[i] + input[j] + input[k]; if x == 2020 { return input[i] * input[j] * inp...
code_fim
hard
{ "lang": "rust", "repo": "21eleven/advent_of_code_2020", "path": "/src/day01.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 21eleven/advent_of_code_2020 path: /src/day01.rs use std::collections::HashSet; #[aoc_generator(day1)] pub fn input_generator(input: &str) -> Vec<u32> { let mut output = input .lines() .map(|n| n.trim().parse().unwrap()) .collect::<Vec<u32>>(); output.sort_unstab...
code_fim
hard
{ "lang": "rust", "repo": "21eleven/advent_of_code_2020", "path": "/src/day01.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> where T: Address + Copy, { self.cs.set_low().ok(); let mut buffer = [reg.addr() & 0x7f]; self.spi.transfer(&mut buffer).map_err(Error::Spi)?; let mut ret_val: [u8; 4] = [0; 4]; self.spi.transfer(&mut ret_val).map_err(Error::Spi)?; self.c...
code_fim
hard
{ "lang": "rust", "repo": "no111u3/tmc5160", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: no111u3/tmc5160 path: /src/lib.rs //! A platform agnostic driver to iterface with the TMC5160 (Trinamic integrated stepper motor controller) //! //! This driver wa built using [`embedded-hal`] traits. //! //! [`embedded-hal`]: https://docs.rs/embedded-hal/0.2 //! //#![deny(missing_docs)] #![no_s...
code_fim
hard
{ "lang": "rust", "repo": "no111u3/tmc5160", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.cs.set_high().ok(); Ok(DataPacket(buffer[0], u32::from_be_bytes(ret_val))) } pub fn write_register<T>(&mut self, reg: T, data: u32) -> Result<DataPacket, Error<E>> where T: Address + Copy, { self.cs.set_low().ok(); let mut buffer = [reg.addr(...
code_fim
hard
{ "lang": "rust", "repo": "no111u3/tmc5160", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> impl<'a> TryFrom<&'a str> for Maps { type Error = Error; fn try_from(value: &'a str) -> Result<Self, Self::Error> { let mut pagemap = Maps::new(); for line in value.lines() { let entry = MappedRegion::try_from(line)?; pagemap.insert(entry); } ...
code_fim
hard
{ "lang": "rust", "repo": "dillonhicks/page-modification-tracking", "path": "/src/maps/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dillonhicks/page-modification-tracking path: /src/maps/mod.rs See //! vdso(7). //! //! [heap] The process's heap. //! //! If the pathname field is blank, this is an anonymous mapping //! as obtained via mmap(2). There is no easy wa...
code_fim
hard
{ "lang": "rust", "repo": "dillonhicks/page-modification-tracking", "path": "/src/maps/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Get the slice of mapped regions corresponding to the given pathname, /// if any exist. pub fn addrs_for_pathname<P>( &self, path: P, ) -> Option<&[AddressRange]> where PathName: TryFrom<P>, { PathName::try_from(path).ok() .and_then(|p...
code_fim
hard
{ "lang": "rust", "repo": "dillonhicks/page-modification-tracking", "path": "/src/maps/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> world.add(Sphere::new(Vec3::new(0.0, 7.0, 0.0), Vec3::new(0.0, 7.0, 0.0), 2.0, Light::new(ConstantTexture::new(4.0, 4.0, 4.0)), 0.0, 1.0)); world.add(Plane::new(Axis::...
code_fim
hard
{ "lang": "rust", "repo": "mandeep/renderama", "path": "/src/scene.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mandeep/renderama path: /src/scene.rs et lookat = Vec3::new(0.0, 0.0, 0.0); let view = Vec3::new(0.0, 1.0, 0.0); let fov = 20.0; let aspect_ratio = (width / height) as f32; let aperture = 0.1; let focus_distance = 10.0; let time0 = 0.0; let time1 = 1.0; let atmosp...
code_fim
hard
{ "lang": "rust", "repo": "mandeep/renderama", "path": "/src/scene.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mandeep/renderama path: /src/scene.rs let material = rand::random::<f32>(); let center: Vec3 = Vec3::new(a as f32 + 0.9 * rand::random::<f32>(), 0.2, b as f32 + 0.9 * rand::random::<f32>()); ...
code_fim
hard
{ "lang": "rust", "repo": "mandeep/renderama", "path": "/src/scene.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // z = ay + bx + c // input data to be classified is [x, y] // perceptron weights are [a, b] // bias is c let mut p = Perceptron::new(3); p.set_learning_rate(0.25); assert_eq!(p.get_dimension(), 3); assert_eq!(p.get_bias(), &0.0); ...
code_fim
hard
{ "lang": "rust", "repo": "mattfedd/rust-practice", "path": "/perceptron/src/perceptron.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mattfedd/rust-practice path: /perceptron/src/perceptron.rs // example, 3 dimensions // z = ax + by + c hyperplane // - if above = true // - if below = false // weights: [a, b, c] // classifying inputs: [x, y, z] -> bool // training inputs: [x, y, z, bool] // perceptron stores: internal [a,...
code_fim
hard
{ "lang": "rust", "repo": "mattfedd/rust-practice", "path": "/perceptron/src/perceptron.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let _ = exe().unwrap(); #[cfg(unix)] { // Rust testing framework occasionally gives us 0, 1, 2, 6 ??? assert_eq!(FdIter::new().unwrap().collect::<Vec<_>>()[..3], [0, 1, 2]); for fd in FdIter::new().unwrap().take(3) { println!("{:?}", fd); // seems to fail on Azure Pipeline's ubuntu-16.04, p...
code_fim
easy
{ "lang": "rust", "repo": "alecmocatta/palaver", "path": "/tests/fd_iter.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alecmocatta/palaver path: /tests/fd_iter.rs use palaver::env::exe; #[cfg(unix)] use palaver::file::FdIter; <|fim_suffix|> let _ = exe().unwrap(); #[cfg(unix)] { // Rust testing framework occasionally gives us 0, 1, 2, 6 ??? assert_eq!(FdIter::new().unwrap().collect::<Vec<_>>()[..3], [0, 1...
code_fim
easy
{ "lang": "rust", "repo": "alecmocatta/palaver", "path": "/tests/fd_iter.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl From<Strahler> for u32 { fn from(from: Strahler) -> u32 { from.0 } }<|fim_prefix|>// repo: Kromey/island_map path: /src/map/watershed/strahler.rs use std::ops::{Add, AddAssign}; /// Strahler Number /// /// https://en.wikipedia.org/wiki/Strahler_number#River_networks #[derive(Debug, ...
code_fim
medium
{ "lang": "rust", "repo": "Kromey/island_map", "path": "/src/map/watershed/strahler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl From<u32> for Strahler { fn from(from: u32) -> Strahler { Strahler(from) } } impl From<Strahler> for u32 { fn from(from: Strahler) -> u32 { from.0 } }<|fim_prefix|>// repo: Kromey/island_map path: /src/map/watershed/strahler.rs use std::ops::{Add, AddAssign}; /// St...
code_fim
medium
{ "lang": "rust", "repo": "Kromey/island_map", "path": "/src/map/watershed/strahler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kromey/island_map path: /src/map/watershed/strahler.rs use std::ops::{Add, AddAssign}; /// Strahler Number /// /// https://en.wikipedia.org/wiki/Strahler_number#River_networks #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct Strahler(u32); <|fim_suffix|> if self ...
code_fim
medium
{ "lang": "rust", "repo": "Kromey/island_map", "path": "/src/map/watershed/strahler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tov/bv-rs path: /src/traits/bits.rs use super::BitsMut; use storage::{BlockType, Address}; use BitVec; /// Read-only bit vector operations. /// /// Minimal complete definition is: /// /// - [`bit_len`] and /// - [`get_block`] or [`get_bit`]. /// /// Note that [`get_block`] in terms of [`get...
code_fim
hard
{ "lang": "rust", "repo": "tov/bv-rs", "path": "/src/traits/bits.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn block_len(&self) -> usize { self.len() } fn get_bit(&self, position: u64) -> bool { let address = Address::new::<Block>(position); self[address.block_index].get_bit(address.bit_offset) } fn get_block(&self, position: usize) -> Block { self[position]...
code_fim
hard
{ "lang": "rust", "repo": "tov/bv-rs", "path": "/src/traits/bits.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Cldfire/minecraft-protocol path: /protocol-derive/src/lib.rs extern crate proc_macro; use proc_macro::TokenStream as TokenStream1; use proc_macro2::Ident; use proc_macro2::TokenStream as TokenStream2; use quote::{quote, TokenStreamExt}; use std::iter::FromIterator; use syn::export::Span; use sy...
code_fim
hard
{ "lang": "rust", "repo": "Cldfire/minecraft-protocol", "path": "/protocol-derive/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut module = None; let mut max_length = None; for meta in meta_list { match meta { NestedMeta::Meta(Meta::NameValue(named_meta)) => match &named_meta.path { path if path.is_ident("with") => match &named_meta.lit { Lit::Str(lit_str) =...
code_fim
hard
{ "lang": "rust", "repo": "Cldfire/minecraft-protocol", "path": "/protocol-derive/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for meta in meta_list { match meta { NestedMeta::Meta(Meta::NameValue(named_meta)) => match &named_meta.path { path if path.is_ident("with") => match &named_meta.lit { Lit::Str(lit_str) => module = Some(lit_str.value()), _ => ...
code_fim
hard
{ "lang": "rust", "repo": "Cldfire/minecraft-protocol", "path": "/protocol-derive/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> EndpointError::Db(DbError::from(err)) } } impl From<InitializationError> for EndpointError { fn from(err: InitializationError) -> EndpointError { EndpointError::Db(DbError::from(err)) } } impl<'r> Responder<'r> for EndpointError { fn respond(self) -> response::Result<'r>...
code_fim
hard
{ "lang": "rust", "repo": "goyox86/blog", "path": "/src/endpoint_error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: goyox86/blog path: /src/endpoint_error.rs use std::fmt; use std::error; use diesel::result::Error as DieselError; use r2d2::{GetTimeout, InitializationError}; use rocket::response; use rocket::response::Responder; use db::DbError; use endpoints::helpers::*; pub type EndpointResult<T> = Resul...
code_fim
hard
{ "lang": "rust", "repo": "goyox86/blog", "path": "/src/endpoint_error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}", ans) }<|fim_prefix|>// repo: kaluna-hart/atcoder-answer-rust path: /abc169/src/bin/c.rs use proconio::{fastout, input}; <|fim_middle|>#[fastout] fn main() { input! { a: u64, b: f64, } let int_b = (b * 100. + 0.5) as u64; let ans: u64 = a * int_b; le...
code_fim
medium
{ "lang": "rust", "repo": "kaluna-hart/atcoder-answer-rust", "path": "/abc169/src/bin/c.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaluna-hart/atcoder-answer-rust path: /abc169/src/bin/c.rs use proconio::{fastout, input}; <|fim_suffix|> println!("{}", ans) }<|fim_middle|>#[fastout] fn main() { input! { a: u64, b: f64, } let int_b = (b * 100. + 0.5) as u64; let ans: u64 = a * int_b; le...
code_fim
medium
{ "lang": "rust", "repo": "kaluna-hart/atcoder-answer-rust", "path": "/abc169/src/bin/c.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: angelini/c-store path: /src/column.rs use std::cmp; use std::fmt; use types::{Aggregation, List, Predicate, Scalar, Test}; macro_rules! select_by_predicate { ( $items: expr, $predicate:expr, $scalar:path ) => {{ match *$predicate { (Test::Equal, $scalar(s)) => $items.ite...
code_fim
hard
{ "lang": "rust", "repo": "angelini/c-store", "path": "/src/column.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (string, offsets) = self.iter() .zip(bitstring) .filter(|&(_, &bit)| bit) .map(|(value, _)| value) .fold((String::new(), vec![]), |mut acc, item| { let previous = if acc.1.len() == 0 { 0 } else ...
code_fim
hard
{ "lang": "rust", "repo": "angelini/c-store", "path": "/src/column.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn is_sorted(&self) -> bool { self.sorted } fn join<'a>(&self, list: List<'a>) -> Vec<usize> { if !self.is_sorted() { panic!("join only supports sorted ancestor"); } match list { List::Floats(floats) => { let mut join_idx...
code_fim
hard
{ "lang": "rust", "repo": "angelini/c-store", "path": "/src/column.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> Rna<'a> { pub fn new(strand: &str) -> Rna { Rna { strand: strand } } } #[derive(Debug, PartialEq)] pub struct Dna<'b> { strand: &'b str, } impl<'b> Dna<'b> { pub fn new(strand: &str) -> Dna { Dna { strand: strand } } pub fn to_rna(&self) -> Rna { ...
code_fim
hard
{ "lang": "rust", "repo": "booyaa/scratchpad", "path": "/rust/move_semantics/src/main.rs", "mode": "spm", "license": "Artistic-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: booyaa/scratchpad path: /rust/move_semantics/src/main.rs #![allow(dead_code)] // Make me compile! Scroll down for hints :) // Make me compile without changing line 9! Scroll down for hints :) pub fn main() { // let mut vec0 = Vec::new(); // // let mut vec1 = fill_vec(vec0); //...
code_fim
hard
{ "lang": "rust", "repo": "booyaa/scratchpad", "path": "/rust/move_semantics/src/main.rs", "mode": "psm", "license": "Artistic-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(dna.to_rna(), rna); } #[derive(Debug, PartialEq)] pub struct Rna<'a> { strand: &'a str, } impl<'a> Rna<'a> { pub fn new(strand: &str) -> Rna { Rna { strand: strand } } } #[derive(Debug, PartialEq)] pub struct Dna<'b> { strand: &'b str, } impl<'b> Dna<'b> { p...
code_fim
hard
{ "lang": "rust", "repo": "booyaa/scratchpad", "path": "/rust/move_semantics/src/main.rs", "mode": "spm", "license": "Artistic-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ekt7be/nphysics path: /src/object/volumetric.rs use std::num::{Zero, One, Real}; use nalgebra::na::{Cast, VecExt, Dim, Iterable, Translation, Indexable}; use nalgebra::na; use ncollide::geom::{Ball, Box, Cylinder, Capsule, Cone, Plane}; use ncollide::geom::{Geom, PlaneGeom, BallGeom, BoxGeom, Co...
code_fim
hard
{ "lang": "rust", "repo": "ekt7be/nphysics", "path": "/src/object/volumetric.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> (mass, center, res) } else if dim == 3 { let m_sq_radius = mass * self.radius() * self.radius(); let m_sq_height = mass * self.half_height() * self.half_height() * Cast::from(4.0); let off_principal = m_sq...
code_fim
hard
{ "lang": "rust", "repo": "ekt7be/nphysics", "path": "/src/object/volumetric.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn add_files() { let mut g = Gist::new(true, true); g.add_file(fake_gist_file(None)); g.add_file(fake_gist_file(None)); assert_eq!(g.files.len(), 2); } #[test] fn emptyness() { let mut g = Gist::new(true, true); assert!(g.is_empt...
code_fim
hard
{ "lang": "rust", "repo": "spk/gist", "path": "/src/gist/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spk/gist path: /src/gist/mod.rs pub mod gist_file; extern crate rustc_serialize; extern crate hyper; use self::rustc_serialize::json::{ToJson, Json}; use self::hyper::Client as HyperClient; use self::hyper::header::{Authorization, Bearer, UserAgent, ContentType}; use self::hyper::status::Statu...
code_fim
hard
{ "lang": "rust", "repo": "spk/gist", "path": "/src/gist/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }