text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let result = fragment .select(&selector) .fold(String::from(""), |mut acc, elem| { acc.push_str(elem.html().as_str()); acc }); Ok(result) } }<|fim_prefix|>// repo: jannisbecker/webmonitor-rs path: /webmonitor-core/sr...
code_fim
hard
{ "lang": "rust", "repo": "jannisbecker/webmonitor-rs", "path": "/webmonitor-core/src/filters/css.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jannisbecker/webmonitor-rs path: /webmonitor-core/src/filters/css.rs use async_trait::async_trait; use scraper::{Html, Selector}; use crate::{ error::{Result, WebmonitorError}, model::CSSFilterOptions, }; use super::FilterApply; pub struct CSSFilter { options: CSSFilterOptions, } ...
code_fim
medium
{ "lang": "rust", "repo": "jannisbecker/webmonitor-rs", "path": "/webmonitor-core/src/filters/css.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct CSSFilter { options: CSSFilterOptions, } impl CSSFilter { pub fn with_options(options: CSSFilterOptions) -> Self { Self { options } } } #[async_trait] impl FilterApply for CSSFilter { fn apply(&self, dom: String) -> Result<String> { let fragment = Html::parse_f...
code_fim
medium
{ "lang": "rust", "repo": "jannisbecker/webmonitor-rs", "path": "/webmonitor-core/src/filters/css.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ennis/openimageio-rs path: /src/input.rs use crate::{ cstring_to_owned, error::get_last_error, typedesc::ImageData, Error, ImageBuffer, ImageSpec, TypeDesc, }; use openimageio_sys as sys; use openimageio_sys::AsStringRef; use std::{ffi::c_void, mem, ops::Range, path::Path, ptr}; /// Ima...
code_fim
hard
{ "lang": "rust", "repo": "ennis/openimageio-rs", "path": "/src/input.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn read_into<T: ImageData>( &self, subimage: usize, miplevel: usize, channels: Range<usize>, out: &mut [T], ) -> Result<(), Error> { if self.spec().width() as usize * self.spec().height() as usize * self.spec().depth() as ...
code_fim
hard
{ "lang": "rust", "repo": "ennis/openimageio-rs", "path": "/src/input.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CircArgs/rust_singly_linked_list path: /src/main.rs mod linked_list; use linked_list::List; <|fim_suffix|> let mut list = List::new(); list.append(1); list.append(2); list.append(4); list.append(5); for i in &list { println!("{:?}", i); } println!("{:?}", ...
code_fim
easy
{ "lang": "rust", "repo": "CircArgs/rust_singly_linked_list", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut list = List::new(); list.append(1); list.append(2); list.append(4); list.append(5); for i in &list { println!("{:?}", i); } println!("{:?}", list); }<|fim_prefix|>// repo: CircArgs/rust_singly_linked_list path: /src/main.rs mod linked_list; use linked_list:...
code_fim
easy
{ "lang": "rust", "repo": "CircArgs/rust_singly_linked_list", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_square_split() { let c = Cube { pos: Vector3::new(-5.0, -5.0, -5.0), size: 10.0, }; let tne = Cube { pos: Vector3::new(0.0, -5.0, -5.0), size: 5.0, }; let tse = Cube { pos: Vector3::...
code_fim
hard
{ "lang": "rust", "repo": "VictorElHajj/rust-n-body", "path": "/src/cube.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VictorElHajj/rust-n-body path: /src/cube.rs use crate::vector::Vector3; use Region::*; #[derive(PartialEq, Debug, Copy, Clone)] pub struct Cube { /// Top left corner of rectangle pub pos: Vector3, pub size: f64, } #[derive(PartialEq, Debug)] pub enum Region { TNE, TSE, T...
code_fim
hard
{ "lang": "rust", "repo": "VictorElHajj/rust-n-body", "path": "/src/cube.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sekey/ssh-agent.rs path: /examples/key_storage.rs use log::info; use ssh_agent::proto::{from_bytes, to_bytes}; use ssh_agent::proto::message::{self, Message, SignRequest}; use ssh_agent::proto::signature::{self, Signature}; use ssh_agent::proto::public_key::PublicKey; use ssh_agent::proto::priv...
code_fim
hard
{ "lang": "rust", "repo": "sekey/ssh-agent.rs", "path": "/examples/key_storage.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.handle_message(message).or_else(|error| { println!("Error handling message - {:?}", error); Ok(Message::Failure) }) } } fn rsa_openssl_from_ssh(ssh_rsa: &RsaPrivateKey) -> Result<Rsa<Private>, Box<dyn Error>> { let n = BigNum::from_slice(&ssh_rsa.n)?;...
code_fim
hard
{ "lang": "rust", "repo": "sekey/ssh-agent.rs", "path": "/examples/key_storage.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize)] pub struct ListProduct { #[serde(rename = "@id")] pub _id: String, pub id: String, #[serde(rename = "wmoCollectiveId")] wmo_collective_id: String, #[serde(rename = "issuingOffice")] issuing_office: String, #[serde(rename = "issuanceT...
code_fim
medium
{ "lang": "rust", "repo": "rhurkes/wx-nwsapi-loader", "path": "/src/domain.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rhurkes/wx-nwsapi-loader path: /src/domain.rs #[derive(Debug, Deserialize)] pub struct ProductsResult { #[serde(rename = "@context")] pub _context: Context, #[serde(rename = "@graph")] pub products: Vec<ListProduct>, } <|fim_suffix|>#[derive(Debug, Serialize, Deserialize)] pub s...
code_fim
hard
{ "lang": "rust", "repo": "rhurkes/wx-nwsapi-loader", "path": "/src/domain.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> model: &dsl::Model, ctx: &Context<Self::Node>) -> Result<Box<Any>> { model.get_string_vector("nodes").map(|children| { let mut c_nodes: Vec<Box<DefaultNode>> = Vec::with_capacity(children.len()); for name in children.iter() { let n_name = format!("{...
code_fim
hard
{ "lang": "rust", "repo": "combust/mleap-rs", "path": "/src/bundle/tform/pipeline.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: combust/mleap-rs path: /src/bundle/tform/pipeline.rs use std::any::*; use bundle::tform::{self, DefaultNode}; use bundle::ser::*; use super::frame; use super::dsl; pub const OP: &'static PipelineOp = &PipelineOp { }; pub struct PipelineModel { children: Vec<Box<DefaultNode>> } pub struct P...
code_fim
hard
{ "lang": "rust", "repo": "combust/mleap-rs", "path": "/src/bundle/tform/pipeline.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn load_model(&self, model: &dsl::Model, ctx: &Context<Self::Node>) -> Result<Box<Any>> { model.get_string_vector("nodes").map(|children| { let mut c_nodes: Vec<Box<DefaultNode>> = Vec::with_capacity(children.len()); for name in children.iter() { ...
code_fim
hard
{ "lang": "rust", "repo": "combust/mleap-rs", "path": "/src/bundle/tform/pipeline.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let s = Rectangle::square(5); println!("Rectangle with equal sides {:?}", s); println!("Square s can hold reactangle o ? {}", s.can_hold(&o)); }<|fim_prefix|>// repo: sum12/rustbook path: /structs/rectangle.rs #[derive(Debug)] struct Rectangle { width: u32, height: u32, } impl Rectan...
code_fim
medium
{ "lang": "rust", "repo": "sum12/rustbook", "path": "/structs/rectangle.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sum12/rustbook path: /structs/rectangle.rs #[derive(Debug)] struct Rectangle { width: u32, height: u32, } impl Rectangle { fn area(&self) -> u32 { self.width * self.height } <|fim_suffix|> println!("rectangle r: {:?}", r); println!("area is : {}", r.area()); ...
code_fim
hard
{ "lang": "rust", "repo": "sum12/rustbook", "path": "/structs/rectangle.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dora-gt/interledger-rs path: /crates/interledger-ildcp/src/server.rs use super::packet::*; use super::Account; use futures::future::ok; use interledger_packet::*; use interledger_service::*; use log::debug; use std::marker::PhantomData; /// A simple service that intercepts incoming ILDCP reques...
code_fim
hard
{ "lang": "rust", "repo": "dora-gt/interledger-rs", "path": "/crates/interledger-ildcp/src/server.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn handle_request(&mut self, request: IncomingRequest<A>) -> Self::Future { if is_ildcp_request(&request.prepare) { let from = request.from.ilp_address(); let builder = IldcpResponseBuilder { ilp_address: &from, asset_code: request.from.a...
code_fim
hard
{ "lang": "rust", "repo": "dora-gt/interledger-rs", "path": "/crates/interledger-ildcp/src/server.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut nk = read_vec::<i64>(); let mut v = read_vec::<i64>(); // v.push(0); v.sort(); v.dedup(); let t = v.clone(); let ans = solve(0, t, nk[1], 0); println!("{}", ans); } fn solve(ans: i64, v: Vec<i64>, k: i64, p: i64) -> i64 { if k == 0 { ans } else if v....
code_fim
hard
{ "lang": "rust", "repo": "helloooooo/prac-algo", "path": "/atcoder/src/abc107c.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: helloooooo/prac-algo path: /atcoder/src/abc107c.rs use std::cmp::min; fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } <|fim_suffix|> read::<String>() .split_whitespace() .m...
code_fim
medium
{ "lang": "rust", "repo": "helloooooo/prac-algo", "path": "/atcoder/src/abc107c.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sonygod/rust-project-euler path: /euler205/src/main.rs use permutator::{cartesian_product}; fn main() { let dices_colin: &[&[u32]] = &[ &[1, 2, 3, 4, 5, 6], &[1, 2, 3, 4, 5, 6], &[1, 2, 3, 4, 5, 6], &[1, 2, 3, 4, 5, 6], &[1, 2, 3, 4, 5, 6], &[...
code_fim
hard
{ "lang": "rust", "repo": "sonygod/rust-project-euler", "path": "/euler205/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut v = vec![0; (face * dice_num + 1) as usize]; for n in 0..face.pow(dice_num) { let str = format_radix(n, face, dice_num); let dice_sum = str .chars() .map(|c| c.to_digit(10).unwrap() + 1) .sum::<u32>(); v[dice_sum as usize] += 1; ...
code_fim
hard
{ "lang": "rust", "repo": "sonygod/rust-project-euler", "path": "/euler205/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mtthw-meyer/misra-rust path: /tests/compile-fail/Rule_10_7.rs fn main() { let u16_a: u16 = 1; let u16_b: u16 = 2; let u32_c: u32 = 3; let _ = u32_c * (u16_a + u<|fim_suffix|> //~^ ERROR cannot multiply `u16` to `u32` }<|fim_middle|>16_b); //~ ERROR mismatched types ...
code_fim
easy
{ "lang": "rust", "repo": "mtthw-meyer/misra-rust", "path": "/tests/compile-fail/Rule_10_7.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> //~^ ERROR cannot multiply `u16` to `u32` }<|fim_prefix|>// repo: mtthw-meyer/misra-rust path: /tests/compile-fail/Rule_10_7.rs fn main() { let u16_a: u16 = 1; let u16_b: u16 = 2; let u32_c: u32 = 3; let _ = u32_c * (u16_a + u<|fim_middle|>16_b); //~ ERROR mismatched types ...
code_fim
easy
{ "lang": "rust", "repo": "mtthw-meyer/misra-rust", "path": "/tests/compile-fail/Rule_10_7.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mgechev/playground path: /rust/fn-borrow.rs fn printit(s: String) -> String { <|fim_suffix|>fn main() { let s = String::from("foo"); let s2 = printit(s); println!("In main: {}", s2); }<|fim_middle|> println!("In fn: {}", s); s }
code_fim
easy
{ "lang": "rust", "repo": "mgechev/playground", "path": "/rust/fn-borrow.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let s = String::from("foo"); let s2 = printit(s); println!("In main: {}", s2); }<|fim_prefix|>// repo: mgechev/playground path: /rust/fn-borrow.rs fn printit(s: String) -> String { println!("In fn: {}", s); s } <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "mgechev/playground", "path": "/rust/fn-borrow.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danielhenrymantilla/rust-require_unsafe_in_body path: /tests/compile_success.rs #![cfg(not(feature = "unit-tests"))] #![allow(unused)] #![forbid(unused_unsafe)] #![cfg_attr(feature = "nightly", feature(async_await), )] <|fim_suffix|>include! { "compile_success/mods.rs" } fn main () {}<...
code_fim
easy
{ "lang": "rust", "repo": "danielhenrymantilla/rust-require_unsafe_in_body", "path": "/tests/compile_success.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>include! { "compile_success/mods.rs" } fn main () {}<|fim_prefix|>// repo: danielhenrymantilla/rust-require_unsafe_in_body path: /tests/compile_success.rs #![cfg(not(feature = "unit-tests"))] #![allow(unused)] #![forbid(unused_unsafe)] #![cfg_attr(feature = "nightly", feature(async_await), )] <...
code_fim
easy
{ "lang": "rust", "repo": "danielhenrymantilla/rust-require_unsafe_in_body", "path": "/tests/compile_success.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if cfg!(target_os = "macos") || cfg!(target_os = "ios") { println!("Think Different!"); } else { println!("Think Same!!!"); } } }<|fim_prefix|>// repo: yingliufengpeng/rust_language path: /ch04_effective_rust/src/section03_conditional_compilation.rs //...
code_fim
easy
{ "lang": "rust", "repo": "yingliufengpeng/rust_language", "path": "/ch04_effective_rust/src/section03_conditional_compilation.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_001() { if cfg!(target_os = "macos") || cfg!(target_os = "ios") { println!("Think Different!"); } else { println!("Think Same!!!"); } } }<|fim_prefix|>// repo: yingliufengpeng/rust_language path: /ch04_effective_rust/src/sectio...
code_fim
easy
{ "lang": "rust", "repo": "yingliufengpeng/rust_language", "path": "/ch04_effective_rust/src/section03_conditional_compilation.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yingliufengpeng/rust_language path: /ch04_effective_rust/src/section03_conditional_compilation.rs //! //! You can also set another attribute based on a cfg variable with //! cfg_attr //! //! #[cfg_attr(a, b)] mod foo2 { } #[cfg(feature="foo")] mod foo { } #[cfg(test)] mod tests { <|fim_suf...
code_fim
easy
{ "lang": "rust", "repo": "yingliufengpeng/rust_language", "path": "/ch04_effective_rust/src/section03_conditional_compilation.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() -> std::io::Result<()> { simple_logger::init_with_level(Level::Info).unwrap(); ctrlc::set_handler(move || { SHOULD_TERMINATE.store(true, Ordering::Relaxed); }) .expect("Error setting Ctrl-C handler"); info!("Starting server..."); let addr: SocketAddr = ([127, 0,...
code_fim
hard
{ "lang": "rust", "repo": "lokmeinmatz/werwolf-online", "path": "/server/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lokmeinmatz/werwolf-online path: /server/src/main.rs #![feature(proc_macro_hygiene, decl_macro)] #![feature(drain_filter)] #[macro_use] extern crate rocket; use crate::api::auth::SessionID; use log::{error, info, Level}; use rocket::response; use rocket::Config; use rocket_contrib::serve::Stat...
code_fim
hard
{ "lang": "rust", "repo": "lokmeinmatz/werwolf-online", "path": "/server/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (params, result) in [ (vec!["--init-size", "1"], Ok(Some(1))), (vec!["--init-size", "0"], Err("init size must be an integer bigger than 0, got '0'".into())), (vec![], Ok(None)), ] { let matches = get_solomon_matches(params.as_slice()); let init_size = g...
code_fim
hard
{ "lang": "rust", "repo": "reinterpretcat/vrp", "path": "/vrp-cli/tests/unit/commands/solve_test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reinterpretcat/vrp path: /vrp-cli/tests/unit/commands/solve_test.rs use super::*; const PRAGMATIC_PROBLEM_PATH: &str = "../examples/data/pragmatic/simple.basic.problem.json"; const SOLOMON_PROBLEM_PATH: &str = "../examples/data/scientific/solomon/C101.25.txt"; const LILIM_PROBLEM_PATH: &str = "...
code_fim
hard
{ "lang": "rust", "repo": "reinterpretcat/vrp", "path": "/vrp-cli/tests/unit/commands/solve_test.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let thread_pool_size = get_environment(&matches, None).map(|e| e.parallelism.thread_pool_size()); assert_eq!(thread_pool_size, result); } } #[test] fn can_use_init_size() { for (params, result) in [ (vec!["--init-size", "1"], Ok(Some(1))), (vec!["--init-size", "0"...
code_fim
hard
{ "lang": "rust", "repo": "reinterpretcat/vrp", "path": "/vrp-cli/tests/unit/commands/solve_test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> .chain(s[i + t.len()..].iter()) .map(|&c| if c == '?' { 'a' } else { c }) .collect::<String>(); println!("{}", ans); } } }<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc076/src/bin/c.rs use proconio::input; use pr...
code_fim
hard
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/abc076/src/bin/c.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc076/src/bin/c.rs use proconio::input; use proconio::marker::Chars; fn main() { input! { s: Chars, t: Chars, }; let index = s .windows(t.len()) .enumerate()<|fim_suffix|> .chain(s[i + t.len().....
code_fim
hard
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/abc076/src/bin/c.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: phsym/prettytable-rs path: /fuzz/fuzz_targets/render.rs #![no_main] use libfuzzer_sys::fuzz_target; use prettytable::{Table, Row, Cell}; <|fim_suffix|>fuzz_target!(|data: Vec<Vec<(String, u8)>>| { fn align_from_u8(x: u8) -> Alignment { match x { 0 => LEFT, 1...
code_fim
medium
{ "lang": "rust", "repo": "phsym/prettytable-rs", "path": "/fuzz/fuzz_targets/render.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> match x { 0 => LEFT, 1 => CENTER, _ => RIGHT, } } let mut pt = prettytable::Table::new(); for row in data { let cells = row.into_iter().map(|x| Cell::new_align(&x.0, align_from_u8(x.1))).collect(); pt.add_row(Row::new(cells));...
code_fim
medium
{ "lang": "rust", "repo": "phsym/prettytable-rs", "path": "/fuzz/fuzz_targets/render.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>fuzz_target!(|data: Vec<Vec<(String, u8)>>| { fn align_from_u8(x: u8) -> Alignment { match x { 0 => LEFT, 1 => CENTER, _ => RIGHT, } } let mut pt = prettytable::Table::new(); for row in data { let cells = row.into_iter().map(|x| C...
code_fim
medium
{ "lang": "rust", "repo": "phsym/prettytable-rs", "path": "/fuzz/fuzz_targets/render.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(s.chars().next_back().unwrap(), '3'); assert_eq!(s.lines().next_back().unwrap(), "3"); } #[test] fn cases() { let s = ez("Hello, World!"); assert_eq!(s.to_lowercase(), "hello, world!"); assert_eq!(s.to_uppercase(), "HELLO, WORLD!"); assert_eq!(s.repeat(3), "Hello, World...
code_fim
hard
{ "lang": "rust", "repo": "Storyyeller/easy_strings", "path": "/tests/test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Storyyeller/easy_strings path: /tests/test.rs // Copyright 2017 Robert Grosse. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This...
code_fim
hard
{ "lang": "rust", "repo": "Storyyeller/easy_strings", "path": "/tests/test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: destenson/dwrensha--seer path: /example/brotli/src/main.rs extern crate brotli; pub fn main() { use std::io::{Cursor, Read}; let mut data: Vec<u8> = vec![0; 64]; let mut stdin = ::std::io::stdin(); stdin.read_exact(&mut data[..]).unwrap(); let data = &data[..]; <|fim_suffix...
code_fim
medium
{ "lang": "rust", "repo": "destenson/dwrensha--seer", "path": "/example/brotli/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut de = brotli::Decompressor::new(&mut data_reader, data.len()); let _ = de.read_exact(&mut result); }<|fim_prefix|>// repo: destenson/dwrensha--seer path: /example/brotli/src/main.rs extern crate brotli; pub fn main() { use std::io::{Cursor, Read}; let mut data: Vec<u8> = vec![0; ...
code_fim
medium
{ "lang": "rust", "repo": "destenson/dwrensha--seer", "path": "/example/brotli/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> use InvalidFormatDescription::*; match self { UnclosedOpeningBracket { index } => { write!(f, "unclosed opening bracket at byte index {index}") } InvalidComponentName { name, index } => { write!(f, "invalid component name ...
code_fim
hard
{ "lang": "rust", "repo": "time-rs/time", "path": "/time/src/error/invalid_format_description.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: time-rs/time path: /time/src/error/invalid_format_description.rs //! Invalid format description use alloc::string::String; use core::fmt; use crate::error; /// The format description provided was not valid. #[non_exhaustive] #[derive(Debug, Clone, PartialEq, Eq)] pub enum InvalidFormatDescrip...
code_fim
hard
{ "lang": "rust", "repo": "time-rs/time", "path": "/time/src/error/invalid_format_description.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: duskmoon314/aw-pac path: /d1-pac/src/audio_codec/ac_dac_drc_lopc.rs #[doc = "Register `ac_dac_drc_lopc` reader"] pub struct R(crate::R<AC_DAC_DRC_LOPC_SPEC>); impl core::ops::Deref for R { type Target = crate::R<AC_DAC_DRC_LOPC_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Targe...
code_fim
hard
{ "lang": "rust", "repo": "duskmoon314/aw-pac", "path": "/d1-pac/src/audio_codec/ac_dac_drc_lopc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> W(writer) } } #[doc = "Field `dac_drc_lopc` reader - The output of the compressor, which is determined by the equation OPC/6.0206. The format is 8.24. (The default value is -40 dB)"] pub type DAC_DRC_LOPC_R = crate::FieldReader<u16, u16>; #[doc = "Field `dac_drc_lopc` writer - The output of th...
code_fim
hard
{ "lang": "rust", "repo": "duskmoon314/aw-pac", "path": "/d1-pac/src/audio_codec/ac_dac_drc_lopc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: creativcoder/Rustacian path: /networking/server.rs use std::net::{TcpListener,TcpStream}; use std::thread; <|fim_suffix|>let server = TcpListener::bind("127.0.0.1:3000").unwrap(); fn handle_client(stream:&TcpStream) { println!("Accepted connection from {:?}",stream.local_addr().unwrap()); } ...
code_fim
easy
{ "lang": "rust", "repo": "creativcoder/Rustacian", "path": "/networking/server.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn handle_client(stream:&TcpStream) { println!("Accepted connection from {:?}",stream.local_addr().unwrap()); } for stream in server.incoming() { match stream { Ok(stream) => { thread::spawn(move|| { handle_client(&stream) }); }, Err(e) => {println!("Connection Error");} } } drop(server...
code_fim
medium
{ "lang": "rust", "repo": "creativcoder/Rustacian", "path": "/networking/server.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("Accepted connection from {:?}",stream.local_addr().unwrap()); } for stream in server.incoming() { match stream { Ok(stream) => { thread::spawn(move|| { handle_client(&stream) }); }, Err(e) => {println!("Connection Error");} } } drop(server); }<|fim_prefix|>// repo: creativcod...
code_fim
medium
{ "lang": "rust", "repo": "creativcoder/Rustacian", "path": "/networking/server.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe impl ClassType for NSButton { #[inherits(NSView, NSResponder, NSObject)] type Super = NSControl; type Mutability = mutability::InteriorMutable; } );<|fim_prefix|>// repo: rust-windowing/winit path: /src/platform_impl/macos/appkit/button.rs use icrate::Foundation::NS...
code_fim
medium
{ "lang": "rust", "repo": "rust-windowing/winit", "path": "/src/platform_impl/macos/appkit/button.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-windowing/winit path: /src/platform_impl/macos/appkit/button.rs use icrate::Foundation::NSObject; use objc2::{extern_class, mutability, ClassType}; <|fim_suffix|>extern_class!( #[derive(Debug, PartialEq, Eq, Hash)] pub(crate) struct NSButton; unsafe impl ClassType for NSButton...
code_fim
easy
{ "lang": "rust", "repo": "rust-windowing/winit", "path": "/src/platform_impl/macos/appkit/button.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AnneKitsune/world_dispatcher path: /src/dispatcher.rs use crate::*; /// A builder that accumulates systems to be inserted into a `Dispatcher`. /// /// For more complex workflows, this builder can have new traits implemented for /// it, using the public `systems` member. #[derive(Default)] pub s...
code_fim
hard
{ "lang": "rust", "repo": "AnneKitsune/world_dispatcher", "path": "/src/dispatcher.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(feature = "parallel")] #[test] #[wasm_bindgen_test] fn dispatch_par_stages() { #[derive(Default)] struct A; #[derive(Default)] struct B; let mut world = World::default(); world.initialize::<A>(); world.initialize::<B>(); ...
code_fim
hard
{ "lang": "rust", "repo": "AnneKitsune/world_dispatcher", "path": "/src/dispatcher.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn hiragana_merges_n(s: &str) -> bool { s.chars().count() == 1 && ["ぁ","あ","ぃ","い","ぅ","う","ぇ","え","ぉ","お","ゃ","や","ゅ","ゆ","ょ","よ","ん"].contains(&s) } pub const HIRAGANA_TO_VOWEL_TABLE: &'static [(&str, &str)] = &[ ("ぁ","あ"),("あ","あ"),("ぃ","い"),("い","い"),("ぅ","う"),("う","う"),("ぇ","え"),("え","え"...
code_fim
hard
{ "lang": "rust", "repo": "mchaver/japonic", "path": "/src/util.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mchaver/japonic path: /src/util.rs use std::cmp::Ordering::{Equal,Greater,Less}; // the table provided must be sorted or it may not return the correct value pub fn lookup(s: &str, table: &'static [(&str,&str)]) -> Option<usize> { match table.binary_search_by(|&(key, _)| { if s == ke...
code_fim
hard
{ "lang": "rust", "repo": "mchaver/japonic", "path": "/src/util.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fitzgen/fart path: /crates/cli/tests/cli.rs use assert_cmd::prelude::*; use std::process::Command; use tempfile::TempDir; fn fart_bin() -> Command { <|fim_suffix|>#[test] fn help() { fart_bin().arg("help").assert().success(); } #[test] fn new() { let dir = TempDir::new().unwrap(); ...
code_fim
medium
{ "lang": "rust", "repo": "fitzgen/fart", "path": "/crates/cli/tests/cli.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let dir = TempDir::new().unwrap(); fart_bin() .arg("new") .arg("my-project") .current_dir(dir.path()) .assert() .success() .stderr(predicates::str::contains("Created new fart project: ")) .stderr(predicates::str::contains("my-project")); ...
code_fim
medium
{ "lang": "rust", "repo": "fitzgen/fart", "path": "/crates/cli/tests/cli.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn new() { let dir = TempDir::new().unwrap(); fart_bin() .arg("new") .arg("my-project") .current_dir(dir.path()) .assert() .success() .stderr(predicates::str::contains("Created new fart project: ")) .stderr(predicates::str::contains("...
code_fim
medium
{ "lang": "rust", "repo": "fitzgen/fart", "path": "/crates/cli/tests/cli.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn boxed_clone(&self) -> Box<dyn Codec> { Box::new(self.clone()) } } #[cfg(test)] mod test { use super::*; use simd_json::OwnedValue; #[test] fn test_null_codec() -> Result<()> { let seed: OwnedValue = OwnedValue::null(); let seed: Value = seed.into(); ...
code_fim
hard
{ "lang": "rust", "repo": "tremor-rs/tremor-runtime", "path": "/src/codec/null.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tremor-rs/tremor-runtime path: /src/codec/null.rs // Copyright 2020-2021, The Tremor Team // // 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.apac...
code_fim
medium
{ "lang": "rust", "repo": "tremor-rs/tremor-runtime", "path": "/src/codec/null.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nisarhassan12/materialize path: /src/storage-client/src/controller/rehydration.rs governed // by the Apache License, Version 2.0. //! Rehydration of storage replicas. //! //! Rehydration is the process of bringing a crashed storage replica back up to //! date. The [`RehydratingStorageClient`] ...
code_fim
hard
{ "lang": "rust", "repo": "nisarhassan12/materialize", "path": "/src/storage-client/src/controller/rehydration.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let timely_config = TimelyConfig { workers: location.workers, // Overridden by the storage `PartitionedState` implementation. process: 0, addresses: location.dataflow_addrs.clone(), // This value is not currently u...
code_fim
hard
{ "lang": "rust", "repo": "nisarhassan12/materialize", "path": "/src/storage-client/src/controller/rehydration.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nisarhassan12/materialize path: /src/storage-client/src/controller/rehydration.rs it observes a send or receive failure while communicating //! with the underlying client, it will reconnect the client and replay the //! command stream. use std::collections::btree_map::Entry; use std::collectio...
code_fim
hard
{ "lang": "rust", "repo": "nisarhassan12/materialize", "path": "/src/storage-client/src/controller/rehydration.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ogoestcc/broker path: /src/resources/errors/users.rs use std::{error::Error, fmt::Display}; use crate::resources::errors::ErrorKind; use super::{InternalServerError, ServiceError}; #[derive(Debug, serde::Serialize)] pub enum UsersError { NotFound, Inactive, Internal(InternalServer...
code_fim
hard
{ "lang": "rust", "repo": "ogoestcc/broker", "path": "/src/resources/errors/users.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl From<UsersError> for ServiceError<UsersError> { fn from(err: UsersError) -> Self { match err { UsersError::Internal(_) => Self::internal(err), _ => Self::not_found(err), } } }<|fim_prefix|>// repo: ogoestcc/broker path: /src/resources/errors/users.rs u...
code_fim
hard
{ "lang": "rust", "repo": "ogoestcc/broker", "path": "/src/resources/errors/users.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<E: Error> From<E> for UsersError { fn from(err: E) -> Self { Self::Internal(InternalServerError::from(err)) } } impl From<UsersError> for ServiceError<UsersError> { fn from(err: UsersError) -> Self { match err { UsersError::Internal(_) => Self::internal(err), ...
code_fim
hard
{ "lang": "rust", "repo": "ogoestcc/broker", "path": "/src/resources/errors/users.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} /// Trait that represent a directory entry inside our FileSystem. Associated type `DirEntry` in our `FileSystem` trait must implement this trait. pub trait DirEntry { type FSError; fn path(&self) -> Result<PathBuf, Self::FSError>; fn file_type(&self) -> Result<FileType, Self::FSError>; ...
code_fim
hard
{ "lang": "rust", "repo": "bnjjj/chicon-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bnjjj/chicon-rs path: /src/lib.rs //! A file abstraction system for Rust //! //! Chicon is a library intends to provide a simple, //! uniform and universal API interacting with any filesystem, //! as an abstraction layer providing traits, types and methods. //! otherwise link to an installed cop...
code_fim
hard
{ "lang": "rust", "repo": "bnjjj/chicon-rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { core::ptr::write(return_ptr, override_return.unwrap_or(upcall_ran)); } } pub(super) fn yield_wait() { let skip_upcall = KERNEL_DATA.with(|refcell| { let mut refmut = refcell.borrow_mut(); let kernel_data = refmut .as_mut() .expect("yiel...
code_fim
hard
{ "lang": "rust", "repo": "pmnxis/libtock-rs", "path": "/unittest/src/kernel/yield_impl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pmnxis/libtock-rs path: /unittest/src/kernel/yield_impl.rs //! Implementations of Yield system calls. use crate::kernel_data::KERNEL_DATA; use crate::{ExpectedSyscall, SyscallLogEntry}; /// # Safety /// It must be valid to write a `libtock_platform::YieldNoWaitReturn` into the /// value pointe...
code_fim
hard
{ "lang": "rust", "repo": "pmnxis/libtock-rs", "path": "/unittest/src/kernel/yield_impl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match kernel_data.expected_syscalls.pop_front() { None => None, Some(ExpectedSyscall::YieldNoWait { override_return }) => override_return, Some(expected_syscall) => expected_syscall.panic_wrong_call("yield-no-wait"), } }); // TODO: Add the Drive...
code_fim
medium
{ "lang": "rust", "repo": "pmnxis/libtock-rs", "path": "/unittest/src/kernel/yield_impl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jakecraige/pals path: /src/set2/aes_cbc.rs use openssl::symm::{Cipher, Crypter, Mode}; use openssl::error::ErrorStack; use set2::pkcs_7_pad; pub fn openssl_ecb_encrypt_block(data: &[u8], key: &[u8]) -> Result<Vec<u8>, ErrorStack> { let cipher = Cipher::aes_128_ecb(); // Must use this m...
code_fim
hard
{ "lang": "rust", "repo": "jakecraige/pals", "path": "/src/set2/aes_cbc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn aes_cbc_encrypt_and_decrypt() { let data = b"Hellooooo"; let key = b"YELLOW SUBMARINE"; let iv = b"YELLOW SUBMARINE"; let ciphertext = aes_cbc::encrypt(data, key, iv).unwrap(); assert_eq!( ciphertext, b"\x3d\x88\xc2\x16\x5...
code_fim
hard
{ "lang": "rust", "repo": "jakecraige/pals", "path": "/src/set2/aes_cbc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Padding is 2, but there's 3 bytes of it. Should only remove two. let plaintext = b"Hello\x02\x02\x02"; let plaintext_no_pad = aes_cbc::remove_padding(plaintext).unwrap(); assert_eq!(plaintext_no_pad, b"Hello\x02"); // Not enough padding let plaintext = b...
code_fim
hard
{ "lang": "rust", "repo": "jakecraige/pals", "path": "/src/set2/aes_cbc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nilern/pegasos path: /interpreter/src/state.rs true, byte_size, "bytes" )]); let pair = new_builtin_type::<PairData>(&mut res, "pair", &[ (true, value_size, "car"), (true, value_size, "cdr") ]); let ...
code_fim
hard
{ "lang": "rust", "repo": "nilern/pegasos", "path": "/interpreter/src/state.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nilern/pegasos path: /interpreter/src/state.rs .map(|(mutable, size, name)| { let name = Symbol::new(state, name).unwrap(); FieldDescriptor::new(state, *mutable, *size, name).unwrap() }) .collect(); Type::n...
code_fim
hard
{ "lang": "rust", "repo": "nilern/pegasos", "path": "/interpreter/src/state.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn insert_after(&mut self, i: usize, v: Value) { let i = self.stack.len().checked_sub(i).unwrap(); self.stack.insert(i, v) } pub fn remove(&mut self, i: usize) -> Option<Value> { self.stack.len().checked_sub(1 + i).map(|i| self.stack.remove(i)) } pub fn im...
code_fim
hard
{ "lang": "rust", "repo": "nilern/pegasos", "path": "/interpreter/src/state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub mod viewer; pub use viewer::Viewer; pub mod profile; pub use profile::Profile; pub mod error_message; pub use error_message::ErrorMessage;<|fim_prefix|>// repo: OSH-2020/x-gkd path: /codes/web工程/seed-frontend/src/entity/mod.rs pub mod avatar; pub use avatar::Avatar; <|fim_middle|>pub mod form; pu...
code_fim
medium
{ "lang": "rust", "repo": "OSH-2020/x-gkd", "path": "/codes/web工程/seed-frontend/src/entity/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub mod image; pub use image::Image; pub mod username; pub use username::Username; pub mod viewer; pub use viewer::Viewer; pub mod profile; pub use profile::Profile; pub mod error_message; pub use error_message::ErrorMessage;<|fim_prefix|>// repo: OSH-2020/x-gkd path: /codes/web工程/seed-frontend/src/e...
code_fim
easy
{ "lang": "rust", "repo": "OSH-2020/x-gkd", "path": "/codes/web工程/seed-frontend/src/entity/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: OSH-2020/x-gkd path: /codes/web工程/seed-frontend/src/entity/mod.rs pub mod avatar; pub use avatar::Avatar; <|fim_suffix|>pub mod viewer; pub use viewer::Viewer; pub mod profile; pub use profile::Profile; pub mod error_message; pub use error_message::ErrorMessage;<|fim_middle|>pub mod form; pu...
code_fim
medium
{ "lang": "rust", "repo": "OSH-2020/x-gkd", "path": "/codes/web工程/seed-frontend/src/entity/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matter-labs/hodor path: /src/iop/trivial_coset_combiner.rs use ff::PrimeField; use super::*; #[derive(Copy, Clone)] pub struct CosetOfSizeTwo; impl CosetInformation for CosetOfSizeTwo { const COSET_SIZE: usize = 2usize; } pub struct TrivialCombiner<F: PrimeField> { _marker: std::marke...
code_fim
medium
{ "lang": "rust", "repo": "matter-labs/hodor", "path": "/src/iop/trivial_coset_combiner.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'c, F: PrimeField> CosetCombiner<F> for TrivialCombiner<F> { const EXPECTED_DEGREE: usize = 2usize; const COSET_SIZE: usize = 2usize; #[inline(always)] fn get_for_natural_index(leafs: &[F], natural_index: usize) -> &F { &leafs[natural_index] } #[inline(always)] ...
code_fim
medium
{ "lang": "rust", "repo": "matter-labs/hodor", "path": "/src/iop/trivial_coset_combiner.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: capnproto/capnproto-rust path: /capnp/src/lib.rs ce shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS ...
code_fim
hard
{ "lang": "rust", "repo": "capnproto/capnproto-rust", "path": "/capnp/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: capnproto/capnproto-rust path: /capnp/src/lib.rs ate that you are running on 8 or 16 bit platform or message is too large. FourByteLengthTooBigForUSize, /// Cannot represent 4 byte segment length as usize. This may indicate that you are running on 8 or 16 bit platform or segment is too ...
code_fim
hard
{ "lang": "rust", "repo": "capnproto/capnproto-rust", "path": "/capnp/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl core::convert::From<core::str::Utf8Error> for Error { fn from(err: core::str::Utf8Error) -> Self { Self::from_kind(ErrorKind::TextContainsNonUtf8Data(err)) } } impl core::convert::From<NotInSchema> for Error { fn from(e: NotInSchema) -> Self { Self::from_kind(ErrorKind::E...
code_fim
hard
{ "lang": "rust", "repo": "capnproto/capnproto-rust", "path": "/capnp/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: standardgalactic/PizzaML path: /src/compiler.rs //! Combine parsing, translation and compilation with a Standard ML compiler use std::io; use combine::*; use combine::primitives::Error; <|fim_suffix|>pub fn parse_and_translate<I, W>(source_code: I, output: &mut W) -> Result<(), ParseError<I>> ...
code_fim
medium
{ "lang": "rust", "repo": "standardgalactic/PizzaML", "path": "/src/compiler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn parse_and_translate<I, W>(source_code: I, output: &mut W) -> Result<(), ParseError<I>> where I: Stream<Item = char>, W: io::Write, { parser::function() .and_then(|func| { translate_function(&func, output).map_err(Error::from) }) .parse(sou...
code_fim
medium
{ "lang": "rust", "repo": "standardgalactic/PizzaML", "path": "/src/compiler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pratik2709/learn-rust path: /traits/src/main.rs // include!("lib.rs"); fn main() { // let tweet = Tweet{ // username: String::from("twttr"), // content: String::from("first tweet ever") // }; // // println!("Summarize tweet: {}", tweet.summarize()); } <|fim_suff...
code_fim
medium
{ "lang": "rust", "repo": "pratik2709/learn-rust", "path": "/traits/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> a+b } #[cfg(test)] mod tests { use super::*; #[test] fn test_add(){ assert_eq!(add(1,2), 3); assert_ne!(add(1,2), 4); } }<|fim_prefix|>// repo: pratik2709/learn-rust path: /traits/src/main.rs // include!("lib.rs"); fn main() { // let tweet = Tweet{ // us...
code_fim
easy
{ "lang": "rust", "repo": "pratik2709/learn-rust", "path": "/traits/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(add(1,2), 3); assert_ne!(add(1,2), 4); } }<|fim_prefix|>// repo: pratik2709/learn-rust path: /traits/src/main.rs // include!("lib.rs"); fn main() { // let tweet = Tweet{ // username: String::from("twttr"), // content: String::from("first tweet ever") ...
code_fim
medium
{ "lang": "rust", "repo": "pratik2709/learn-rust", "path": "/traits/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (source_kvs, changes, expected_kvs) in test_cases.into_iter() { let expected_kvs = expected_kvs .into_iter() .flatten() .map(|i| (Key::from(i), Value::from(i))) .collect::<Vec<_>>(); let cache = Fixity::mem...
code_fim
hard
{ "lang": "rust", "repo": "leeola/fixity", "path": "/src/core/primitive/prollytree/refimpl/update.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leeola/fixity path: /src/core/primitive/prollytree/refimpl/update.rs use { crate::{ core::{ cache::{CacheRead, CacheWrite}, primitive::prollytree::{ refimpl::{Create, Read}, roller::Config as RollerConfig, }, ...
code_fim
hard
{ "lang": "rust", "repo": "leeola/fixity", "path": "/src/core/primitive/prollytree/refimpl/update.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/definition-reachable/private-use.rs // Check that private use statements can be used by <|fim_suffix|> assert_eq!(private_use_macro::m!(), 57); }<|fim_middle|>// run-pass // aux-build:private-use-macro.rs extern crate private_use_macro; fn...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/definition-reachable/private-use.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(private_use_macro::m!(), 57); }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/definition-reachable/private-use.rs // Check that private use statements can be used by <|fim_middle|>// run-pass // aux-build:private-use-macro.rs extern crate private_use_macro; fn...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/definition-reachable/private-use.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mashtizadeh/wasmtime path: /crates/lightbeam/src/error.rs use capstone; use thiserror::Error; use wasmparser::BinaryReaderError; #[derive(Error, PartialEq, Eq, Clone, Debug)] pub enum Error { #[error("Disassembler error: {0}")] Disassembler(String), #[error("Assembler error: {0}")]...
code_fim
medium
{ "lang": "rust", "repo": "mashtizadeh/wasmtime", "path": "/crates/lightbeam/src/error.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }