text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: thomasmatecki/jq2rs path: /jq2rs/src/modules/oniguruma/src/st.rs static mut type_numhash: st_hash_type = unsafe { { let mut init = st_hash_type{compare: ::std::mem::transmute::<Option<unsafe extern "C" fn(_: ...
code_fim
hard
{ "lang": "rust", "repo": "thomasmatecki/jq2rs", "path": "/jq2rs/src/modules/oniguruma/src/st.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> next = (*ptr).next; hash_val = (*ptr).hash.wrapping_rem(new_num_bins as libc::c_uint); (*ptr).next = *new_bins.offset(hash_val as isize); let ref mut fresh2 = *new_bins.offset(hash_val as isize); *fresh2 = ptr; ptr = next } ...
code_fim
hard
{ "lang": "rust", "repo": "thomasmatecki/jq2rs", "path": "/jq2rs/src/modules/oniguruma/src/st.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let stdin = r#" 3 higashikyoto kupconsitetokyotokyoto goodluckandhavefun "#; let stdout = r#" 1 2 0 "#; assert_cli::Assert::cargo_binary(NAME) .stdin(stdin) .stdout() .is(stdout) .unwrap(); }<|fim_prefix|>// repo: akirasosa/rust-practice path: /tests/ku...
code_fim
easy
{ "lang": "rust", "repo": "akirasosa/rust-practice", "path": "/tests/kupc2015_a.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: akirasosa/rust-practice path: /tests/kupc2015_a.rs extern crate assert_cli; const NAME: &str = "kupc2015_a"; <|fim_suffix|> let stdin = r#" 3 higashikyoto kupconsitetokyotokyoto goodluckandhavefun "#; let stdout = r#" 1 2 0 "#; assert_cli::Assert::cargo_binary(NAME) ...
code_fim
easy
{ "lang": "rust", "repo": "akirasosa/rust-practice", "path": "/tests/kupc2015_a.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FreeMasen/RESS path: /tests/moz_central/main.rs #![cfg(all(test, feature = "moz_central"))] extern crate flate2; extern crate ress; extern crate tar; use flate2::read::GzDecoder; use ress::*; use std::fs::read_to_string; use std::path::{Path, PathBuf}; <|fim_suffix|> let _ = pretty_env_logg...
code_fim
medium
{ "lang": "rust", "repo": "FreeMasen/RESS", "path": "/tests/moz_central/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn walk(path: &Path) { let files: Vec<PathBuf> = path .read_dir() .unwrap() .map(|e| e.unwrap().path()) .collect(); files.iter().for_each(|path| { if path.is_file() { if let Some(ext) = path.extension() { if ext == "js" { ...
code_fim
hard
{ "lang": "rust", "repo": "FreeMasen/RESS", "path": "/tests/moz_central/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: morristech/diagwiz path: /src/diagrams/base/src/lib.rs use std::fmt; #[derive(Debug)] pub enum TransformError { ParseError(String), } <|fim_suffix|> match self { TransformError::ParseError(msg) => write!(f, "Invalid syntax:\n{}", msg), } } }<|fim_middle|>impl...
code_fim
medium
{ "lang": "rust", "repo": "morristech/diagwiz", "path": "/src/diagrams/base/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self { TransformError::ParseError(msg) => write!(f, "Invalid syntax:\n{}", msg), } } }<|fim_prefix|>// repo: morristech/diagwiz path: /src/diagrams/base/src/lib.rs use std::fmt; #[derive(Debug)] pub enum TransformError { ParseError(String), } <|fim_middle|>impl...
code_fim
medium
{ "lang": "rust", "repo": "morristech/diagwiz", "path": "/src/diagrams/base/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Fishrock123/rust-inventory path: /tests/inventory.rs extern crate rust_inventory; use rust_inventory::inventory::Inventory; use rust_inventory::item::Item; <|fim_suffix|> let mut inv = Inventory::<TestItem>::new(5); assert!(inv.give(TestItem { _data: 0 }, 3)); assert!(inv.take("Legen...
code_fim
hard
{ "lang": "rust", "repo": "Fishrock123/rust-inventory", "path": "/tests/inventory.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn new_inventory() { let inv = Inventory::<TestItem>::new(5); assert_eq!(inv.len(), 5); } #[test] fn give_take() { let mut inv = Inventory::<TestItem>::new(5); assert!(inv.give(TestItem { _data: 0 }, 3)); assert!(inv.take("Legendary Motor Lance", 2)); assert!(inv.give(Test...
code_fim
medium
{ "lang": "rust", "repo": "Fishrock123/rust-inventory", "path": "/tests/inventory.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lazareviczoran/advent-of-code-2018 path: /014-chocolate-charts/src/main.rs fn main() { let input = 637061; println!( "Day 14: Chocolate Charts part1 solution\n{:?}", find_score_after_nth_recipe(input) ); println!( "Day 14: Chocolate Charts part2 solution\n{:?}", find_nu...
code_fim
hard
{ "lang": "rust", "repo": "lazareviczoran/advent-of-code-2018", "path": "/014-chocolate-charts/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(find_score_after_nth_recipe(2018), 5941429882); } #[test] fn part2_test1() { assert_eq!(find_num_of_recipes_before(9), 13); } #[test] fn part2_test2() { assert_eq!(find_num_of_recipes_before(5), 9); } #[test] fn part2_test3() { assert_eq!(find_num_of_recipes...
code_fim
hard
{ "lang": "rust", "repo": "lazareviczoran/advent-of-code-2018", "path": "/014-chocolate-charts/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>der) {} //! //! // Conditional copying for ultimate hackery. //! fn opportunistic_elf_processing(buf: &[u8]) { //! if plain::is_aligned::<ELF64Header>(buf) { //! // No copy necessary. //! let elf_ref = ELF64Header::from_bytes(buf); //! process_elf(elf_ref); //! } else { //! // Not...
code_fim
hard
{ "lang": "rust", "repo": "mozilla/gecko-dev", "path": "/third_party/rust/plain/src/lib.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>! //! # fn main() {} //! //! ``` //! //! # Comparison to [`pod`](https://crates.io/crates/pod) //! //! [`pod`](https://crates.io/crates/pod) is another crate created to help working with plain data. //! The major difference between `pod` and `plain` is scope. //! //! `plain` currently provides only a few ...
code_fim
hard
{ "lang": "rust", "repo": "mozilla/gecko-dev", "path": "/third_party/rust/plain/src/lib.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mozilla/gecko-dev path: /third_party/rust/plain/src/lib.rs //! A small Rust library that allows users to interpret arrays of bytes //! as certain kinds of structures safely. //! //! This crate provides an unsafe trait [`Plain`](trait.Plain.html), which the user //! of the crate uses to mark type...
code_fim
hard
{ "lang": "rust", "repo": "mozilla/gecko-dev", "path": "/third_party/rust/plain/src/lib.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_handle_e2e() { let dir = tempdir().unwrap(); handle(String::from(DEFAULT_BLOCKCHAIN), PathBuf::from(dir.path())).unwrap(); // spot check move starter files let expected_starter_content = String::from_utf8_lossy(include_bytes!("../../move...
code_fim
hard
{ "lang": "rust", "repo": "deadBlueShark/diem", "path": "/shuffle/cli/src/new.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: deadBlueShark/diem path: /shuffle/cli/src/new.rs // Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use anyhow::Result; use diem_genesis_tool::validator_builder::ValidatorConfig; use diem_types::{account_address::AccountAddress, on_chain_config::VMPublishingOptio...
code_fim
hard
{ "lang": "rust", "repo": "deadBlueShark/diem", "path": "/shuffle/cli/src/new.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn from_proto(proto: ProtoGrpcClientParameters) -> Result<Self, TryFromProtoError> { Ok(Self { connect_timeout: proto.connect_timeout.into_rust()?, http2_keep_alive_interval: proto.http2_keep_alive_interval.into_rust()?, http2_keep_alive_timeout: proto.http2...
code_fim
hard
{ "lang": "rust", "repo": "nisarhassan12/materialize", "path": "/src/service/src/params.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nisarhassan12/materialize path: /src/service/src/params.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, in accordanc...
code_fim
hard
{ "lang": "rust", "repo": "nisarhassan12/materialize", "path": "/src/service/src/params.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// Gets the page for addr, which is the upper byte. So for example, the address // 0xf0cc is on page 0xf0. The address 0x00ff is on page 0x00. Each page // consists of 256 addresses. pub fn page(addr: u16) -> u8 { (addr >> 8) as u8 } // Determines whether addr1 and addr2 are on the same page, or whet...
code_fim
hard
{ "lang": "rust", "repo": "patlillis/neskimo", "path": "/src/utils/paging.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if page1 > page2 { PageCross::Backwards } else if page1 < page2 { PageCross::Forwards } else { PageCross::Same } }<|fim_prefix|>// repo: patlillis/neskimo path: /src/utils/paging.rs use std::fmt; #[derive(PartialEq, Debug)] pub enum PageCross { Same, Backw...
code_fim
hard
{ "lang": "rust", "repo": "patlillis/neskimo", "path": "/src/utils/paging.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: patlillis/neskimo path: /src/utils/paging.rs use std::fmt; #[derive(PartialEq, Debug)] pub enum PageCross { Same, Backwards, Forwards, } <|fim_suffix|> match *self { PageCross::Same => write!(f, "Same"), PageCross::Backwards => write!(f, "Backwards"),...
code_fim
medium
{ "lang": "rust", "repo": "patlillis/neskimo", "path": "/src/utils/paging.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(result.to_string(), "[0, 1, 0, 1, 0]") }<|fim_prefix|>// repo: StackCrash/kryptos path: /tests/integration_tests.rs extern crate regex; use regex::{Captures, Regex}; #[test] fn test_regex() { <|fim_middle|> let binary = "01010"; let re = Regex::new(r"[01]{5}").unwrap(); let r...
code_fim
hard
{ "lang": "rust", "repo": "StackCrash/kryptos", "path": "/tests/integration_tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: StackCrash/kryptos path: /tests/integration_tests.rs extern crate regex; use regex::{Captures, Regex}; #[test] fn test_regex() { <|fim_suffix|> assert_eq!(result.to_string(), "[0, 1, 0, 1, 0]") }<|fim_middle|> let binary = "01010"; let re = Regex::new(r"[01]{5}").unwrap(); let r...
code_fim
hard
{ "lang": "rust", "repo": "StackCrash/kryptos", "path": "/tests/integration_tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xeals/subs path: /src/conf.rs use config::{Config, Environment, File}; use std::path::PathBuf; #[derive(Debug, Deserialize, Serialize)] #[serde(default)] pub struct Conf { pub socket: PathBuf, pub cache: PathBuf, pub url: String, pub username: String, pub password: String, }...
code_fim
medium
{ "lang": "rust", "repo": "xeals/subs", "path": "/src/conf.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let runtime = dirs::runtime_dir().unwrap_or("/tmp".into()); Conf { socket: runtime.join("subs.sock"), cache: dirs::cache_dir() .expect("Unable to find a valid path for cache, your platform might not be supported") .join("subs"), ...
code_fim
medium
{ "lang": "rust", "repo": "xeals/subs", "path": "/src/conf.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> part1 += union.count_ones(); part2 += intersection.count_ones(); (part1, part2) } #[async_std::test] async fn test() -> Result<(), InputError> { let input = get_input(2020, 6).await?; assert_eq!(solve(&input), (6726, 3316)); Ok(()) } #[cfg(test)] mod benches { extern crate t...
code_fim
hard
{ "lang": "rust", "repo": "timvermeulen/advent-of-code", "path": "/src/solutions/year2020/day06.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timvermeulen/advent-of-code path: /src/solutions/year2020/day06.rs #[cfg(test)] use super::*; pub fn solve(input: &str) -> (u32, u32) { const NONE: u32 = 0; const ALL: u32 = (1 << 27) - 2; const MASK: u8 = (1 << 5) - 1; <|fim_suffix|> bits = NONE; } else ...
code_fim
hard
{ "lang": "rust", "repo": "timvermeulen/advent-of-code", "path": "/src/solutions/year2020/day06.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> else if #[cfg(feature = "slave")] { match cx.resources.motion_channel_c.dequeue() { Some(rpm) => { let r = cx.spawn.motor_control(MotorControlEvent::SetRpm(rpm)); cx.spawn.motor_control(MotorControlEvent::RequestTelemetry).ok(); ...
code_fim
hard
{ "lang": "rust", "repo": "romixlab/uwb-playground", "path": "/src/tasks/channel_event.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: romixlab/uwb-playground path: /src/tasks/channel_event.rs use rtt_target::rprintln; use crate::motion::{ Rpm, MotorControlEvent }; use cfg_if::cfg_if; use rtic::Mutex; pub fn channel_event(mut cx: crate::channel_event::Context) { cfg_if! { if #[cfg(feature = "master")] { ...
code_fim
hard
{ "lang": "rust", "repo": "romixlab/uwb-playground", "path": "/src/tasks/channel_event.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: magiclen/vcard path: /src/values/float.rs use super::*; validated_customized_primitive_number!(pub Float, f64); <|fim_suffix|> f.write_fmt(format_args!("{:.7}", self.get_number()))?; Ok(()) } }<|fim_middle|>impl Value for Float { fn fmt(&self, f: &mut Formatter) -> Resu...
code_fim
medium
{ "lang": "rust", "repo": "magiclen/vcard", "path": "/src/values/float.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> f.write_fmt(format_args!("{:.7}", self.get_number()))?; Ok(()) } }<|fim_prefix|>// repo: magiclen/vcard path: /src/values/float.rs use super::*; validated_customized_primitive_number!(pub Float, f64); <|fim_middle|>impl Value for Float { fn fmt(&self, f: &mut Formatter) -> Resu...
code_fim
medium
{ "lang": "rust", "repo": "magiclen/vcard", "path": "/src/values/float.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DavidEGrayson/minecraft-rust path: /minecraft-bot/src/support/login.rs extern crate std; use std::io::prelude::*; use std::error::Error; use std::convert::From; use std::fmt::Display; use std::fmt::Formatter; use std::net::TcpStream; use protocol; use protocol::pack; use protocol::packet; use p...
code_fim
hard
{ "lang": "rust", "repo": "DavidEGrayson/minecraft-rust", "path": "/minecraft-bot/src/support/login.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn login(stream : &mut TcpStream, server_address : &str, server_port : u16, username : &str) -> LoginResult { { let handshake = packet::Handshake { protocol_version: 109, // current protocol version server_address: server_address.to_owned(), ...
code_fim
hard
{ "lang": "rust", "repo": "DavidEGrayson/minecraft-rust", "path": "/minecraft-bot/src/support/login.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sigi64/libfrps-rs path: /src/common.rs /* ====================================================================== The FastRPC protocol 1.0 specification FastRPC uses 8 data types: 6 scalar (integer, boolean, double, string, date and binary) and 2 structured (struct and array). It also has 3 non-d...
code_fim
hard
{ "lang": "rust", "repo": "sigi64/libfrps-rs", "path": "/src/common.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> [INT (fault number)] [STRING (fault message)] Additional type info should be zero. ====================================================================== FastRPC 3.0 introduces two changes to the protocol - integer unification and timestamp field enlargement in DateTime type. The integer value is unifi...
code_fim
hard
{ "lang": "rust", "repo": "sigi64/libfrps-rs", "path": "/src/common.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/harbourmaster path: /src/network.rs use crate::Client; use shiplift::{builder::NetworkCreateOptionsBuilder, NetworkCreateOptions}; /// Abstraction of a Docker network pub struct Network { id: String, client: Client, } <|fim_suffix|> NetworkBuilder { client: C...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/harbourmaster", "path": "/src/network.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub async fn build(self) -> Result<Network, shiplift::Error> { let create_info = self.client.networks().create(&self.options.build()).await?; Ok(Network { id: create_info.id, client: self.client, }) } }<|fim_prefix|>// repo: isgasho/harbourmaster p...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/harbourmaster", "path": "/src/network.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fveilly/opentype-rs path: /src/table.rs use error::Error; use tables::TableTag; use table_record::{compute_checksum, compute_checksum_for_head}; pub struct Table<'otf> { buf: &'otf[u8], tag: TableTag, checksum: u32, offset: usize, length: usize } impl<'otf> Table<'otf> { ...
code_fim
hard
{ "lang": "rust", "repo": "fveilly/opentype-rs", "path": "/src/table.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> assert!(Table::new( bytes, TableTag::Cmap,0, 13, 5).as_slice().is_err()); } #[test] fn case_table_record_invalid_length() { let bytes: &[u8] = &[0x05, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x05, 0x57, 0x6F, 0x72, 0x6C, 0x64]; assert!(Table::new( ...
code_fim
hard
{ "lang": "rust", "repo": "fveilly/opentype-rs", "path": "/src/table.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>fn read_input(filename: &str) -> Result<Vec<String>> { Ok( BufReader::new(File::open(filename)?) .lines() .map(|v| v.unwrap().parse().unwrap()) .collect(), ) } #[cfg(test)] mod tests { use super::*; #[test] fn check_part_one() { let data = vec![ "1-3 a: abcde", "1-3 b: cdefg,", ...
code_fim
medium
{ "lang": "rust", "repo": "aseaman/advent-of-code", "path": "/2020/rs/day02/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aseaman/advent-of-code path: /2020/rs/day02/src/main.rs use std::fs::File; use std::io::{BufRead, BufReader, Result}; fn main() { <|fim_suffix|> #[test] fn check_part_one() { let data = vec![ "1-3 a: abcde", "1-3 b: cdefg,", "2-9 c: ccccccccc" ]; assert_eq!(part_one(&data), 2); ...
code_fim
hard
{ "lang": "rust", "repo": "aseaman/advent-of-code", "path": "/2020/rs/day02/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/third-party-api-clients path: /slack/src/admin_users.rs use crate::Client; use crate::ClientResult; pub struct AdminUsers { pub client: Client, } impl AdminUsers { #[doc(hidden)] pub fn new(client: Client) -> Self { AdminUsers { client } } /** * ...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/third-party-api-clients", "path": "/slack/src/admin_users.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>te::Message { body: None, content_type: Some("application/x-www-form-urlencoded".to_string()), }, ) .await } /** * This function performs a `POST` to the `/admin.users.setOwner` endpoint. * * Set an exis...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/third-party-api-clients", "path": "/slack/src/admin_users.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize)] struct ValidationError { flow: String, start_line: u32, start_column: u32, end_line: Option<u32>, end_column: Option<u32>, message: String, } pub fn handler(body: CsmlBot) -> Result<serde_json::Value, Error> { let response = match valid...
code_fim
hard
{ "lang": "rust", "repo": "CSML-by-Clevy/csml-engine", "path": "/bindings/aws_lambda/src/routes/validate.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> CsmlResult { flows: _, extern_flows: _, warnings: _, errors: Some(errors), } => { let mut errors_array = Vec::new(); for (_, error_info) in errors.iter().enumerate() { errors_array.push(ValidationError ...
code_fim
hard
{ "lang": "rust", "repo": "CSML-by-Clevy/csml-engine", "path": "/bindings/aws_lambda/src/routes/validate.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CSML-by-Clevy/csml-engine path: /bindings/aws_lambda/src/routes/validate.rs use csml_engine::{validate_bot, CsmlResult}; use csml_interpreter::data::csml_bot::CsmlBot; use serde::{Deserialize, Serialize}; use crate::Error; #[derive(Debug, Serialize, Deserialize)] struct ValidateBotResponse { ...
code_fim
hard
{ "lang": "rust", "repo": "CSML-by-Clevy/csml-engine", "path": "/bindings/aws_lambda/src/routes/validate.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!((66, 16), sum_of_metadata_from_file("src/res/day_8_ex.txt")); assert_eq!( (25737, 16175), sum_of_metadata_from_file("src/res/day_8.txt") ); } } fn main() { // let string = read_string_from_file("src/res/day_8_ex.txt").unwrap(); // Sum = 6...
code_fim
hard
{ "lang": "rust", "repo": "falukropp/advent-of-code-2018-rust", "path": "/src/bin/day_8_2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn sum_of_metadata_from_file(path: &str) -> (u32, usize) { let string = read_string_from_file(path).unwrap(); // 25737 let numbers: Vec<u32> = string .split_whitespace() .map(|s| s.parse().unwrap()) .collect(); sum_of_metadata(&numbers) } #[cfg(test)] mod tests { ...
code_fim
hard
{ "lang": "rust", "repo": "falukropp/advent-of-code-2018-rust", "path": "/src/bin/day_8_2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: falukropp/advent-of-code-2018-rust path: /src/bin/day_8_2.rs extern crate regex; use std::fs::File; use std::io::Read; use std::vec::Vec; type GenError = Box<std::error::Error>; fn read_string_from_file(path: &str) -> Result<String, GenError> { let mut f = File::open(path)?; let mut s...
code_fim
hard
{ "lang": "rust", "repo": "falukropp/advent-of-code-2018-rust", "path": "/src/bin/day_8_2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MaxOhn/Bathbot path: /bathbot/src/commands/osu/popular/maps.rs use std::sync::Arc; use bathbot_model::OsuTrackerPpEntry; use bathbot_util::constants::OSUTRACKER_ISSUE; use eyre::Result; use rkyv::{Deserialize, Infallible}; use super::PopularMapsPp; use crate::{ active::{impls::PopularMapsP...
code_fim
hard
{ "lang": "rust", "repo": "MaxOhn/Bathbot", "path": "/bathbot/src/commands/osu/popular/maps.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> let pagination = PopularMapsPagination::builder() .pp(pp) .entries(entries.into_boxed_slice()) .msg_owner(command.user_id()?) .build(); ActiveMessages::builder(pagination) .start_by_update(true) .begin(ctx, &mut command) .await } impl Popul...
code_fim
hard
{ "lang": "rust", "repo": "MaxOhn/Bathbot", "path": "/bathbot/src/commands/osu/popular/maps.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eholk/SciRust path: /src/SciRust/matrix/algorithms.rs #![allow(uppercase_variables)] use std::num; use matrix::{BasicMatrix, Create, SubMatrix, TransposeMatrix, Vector, col, row}; use matrix::generate::zero_matrix; pub fn dot<T: num::Num, L: Vector<T>, R: Vector<T>>...
code_fim
hard
{ "lang": "rust", "repo": "eholk/SciRust", "path": "/src/SciRust/matrix/algorithms.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let N = M.num_rows(); if N == 1 { Create::<T>::create(1, 1, |i, j| num::from_int::<T>(1).unwrap() / M.get(i, j)) } else { let N2 = N / 2; let N2a = N - N2; // the convert is needed to avoid infinite expansion of // monomorphic functions. The type v...
code_fim
hard
{ "lang": "rust", "repo": "eholk/SciRust", "path": "/src/SciRust/matrix/algorithms.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ethbmc/ethbmc path: /esvm/src/se/symbolic_executor/call_ops.rs _op(&to, res, false, |to, addr, id, mut check| { // add constraint along this path check.push_constraint(eql(&to, &addr)); let balance = Arc::clone(&check.env.get_account(&id).balance); ...
code_fim
hard
{ "lang": "rust", "repo": "ethbmc/ethbmc", "path": "/esvm/src/se/symbolic_executor/call_ops.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> trans.push((call, edge_call_ret())); } else if call.env.get_account(&id).code().is_some() && cfg!(feature = "calls") { match call_type { CallType::Call | CallType::StaticCall => { info!( "Ex...
code_fim
hard
{ "lang": "rust", "repo": "ethbmc/ethbmc", "path": "/esvm/src/se/symbolic_executor/call_ops.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ethbmc/ethbmc path: /esvm/src/se/symbolic_executor/call_ops.rs unt) } else { s.env.get_addresses() }; for (addr, id) in accounts { let fork = s.fork(); if let Some(mut transition) = f(to, &addr, id, fork) { states.append...
code_fim
hard
{ "lang": "rust", "repo": "ethbmc/ethbmc", "path": "/esvm/src/se/symbolic_executor/call_ops.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let out_buf: Vec<f32> = pair.coef .iter() .take(pair.coef.len() / 2 + 1) .map(|c| c.norm().log10()) .map(|val| { let positive_val = if val < 0.0 { 0.0 } else { val }; if positive_val > max_val { max...
code_fim
hard
{ "lang": "rust", "repo": "duane/audiotoolbox", "path": "/spectrogram/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: duane/audiotoolbox path: /spectrogram/src/lib.rs extern crate apodize; extern crate fftw; extern crate num_complex; extern crate futures; extern crate tokio_core; extern crate tokio_io; use apodize::hanning_iter; #[derive(Clone)] pub struct ChunksWithHop<'a, T: 'a> { v: &'a [T], size:...
code_fim
hard
{ "lang": "rust", "repo": "duane/audiotoolbox", "path": "/spectrogram/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn stft(signal: &Vec<f32>, samples_per_second: usize, window_size: usize, hop: isize) -> SpectrogramResult { let window: Vec<f32> = hanning_iter(window_size).map(|c| c as f32).collect(); let mut pair = fftw::Pair::c2c_1d(window_size, fftw::SIGN::FFTW_FORWA...
code_fim
hard
{ "lang": "rust", "repo": "duane/audiotoolbox", "path": "/spectrogram/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 4lDO2/fal-rs path: /fal-backend-ext4/src/extents/pairs.rs use std::borrow::Cow; use crate::{ allocate_block_bytes, disk::BlockKind, extents::{ExtentLeaf, ExtentTree, ExtentTreeBody}, inode::InodeIoError, Filesystem, }; type Path<'a> = Vec<(Cow<'a, ExtentTree>, usize)>; ///...
code_fim
hard
{ "lang": "rust", "repo": "4lDO2/fal-rs", "path": "/fal-backend-ext4/src/extents/pairs.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> continue; } let (last, index) = self.current_path.last_mut().unwrap(); match last.body { ExtentTreeBody::Internal(ref int) => { let subtree_block = int[*index].physical_leaf_block(); // XXX: Try/c...
code_fim
hard
{ "lang": "rust", "repo": "4lDO2/fal-rs", "path": "/fal-backend-ext4/src/extents/pairs.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> // This can be the case for functions inlined from another crate if span.is_dummy() { // FIXME(simulacrum): Probably can't happen; remove. return FunctionDebugContext::FunctionWithoutDebugInfo; } let def_id = instance.def_id(); let containin...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_codegen_llvm/debuginfo/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/librustc_codegen_llvm/debuginfo/mod.rs variable_kind: VariableKind, span: Span, ) { assert!(!dbg_context.get_ref(span).source_locations_enabled); let cx = self.cx(); let file = span_start(cx, span).file; ...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_codegen_llvm/debuginfo/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Arguments types if cx.sess().target.target.options.is_like_msvc { // FIXME(#42800): // There is a bug in MSDIA that leads to a crash when it encounters // a fixed-size array of `u8` or something zero-sized in a // f...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_codegen_llvm/debuginfo/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /*变换 */ let th = c * (x - x1) / x + 1.0; /*+b */ let x2 = (l + y1) * th.cos() + x0; let y2 = -(l + y1) * th.sin() + y0; /*画线 */ if a == 0.0 { context.move_to(x2, y2 / 1.5); ...
code_fim
hard
{ "lang": "rust", "repo": "planet0104/art_pattern", "path": "/src/chapter2/sample15.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: planet0104/art_pattern path: /src/chapter2/sample15.rs use std::f64::consts::PI; use stdweb::web::CanvasRenderingContext2d; pub fn draw(context: &CanvasRenderingContext2d) { let text = r#" 原图中任意点的P(X1,Y1)经过扇形变换后,点P2(X2,Y2)的坐标为: X2 = [L + Y1] * COS[TH] + X0 Y2 = -[L + Y1] * SIN[T...
code_fim
hard
{ "lang": "rust", "repo": "planet0104/art_pattern", "path": "/src/chapter2/sample15.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> /*画线 */ if a == 0.0 { context.move_to(x2, y2 / 1.5); } else { context.line_to(x2, y2 / 1.5); } a += PI / 64.0; } py += y / 4.0; } px += x / 8.0;...
code_fim
hard
{ "lang": "rust", "repo": "planet0104/art_pattern", "path": "/src/chapter2/sample15.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stevendanna/rust-memcache path: /src/protocol/ascii.rs use std::collections::HashMap; use std::fmt; use std::io::{BufRead, BufReader, Read, Write}; use client::Stats; use error::MemcacheError; use stream::Stream; use value::{FromMemcacheValue, ToMemcacheValue}; #[derive(Default)] pub struct Op...
code_fim
hard
{ "lang": "rust", "repo": "stevendanna/rust-memcache", "path": "/src/protocol/ascii.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> result.insert(key.to_string(), FromMemcacheValue::from_memcache_value(buffer, flags)?); // read the rest \r\n let mut s = String::new(); let _ = self.reader.read_line(&mut s)?; if s != "\r\n" { return Err(MemcacheError::ClientErr...
code_fim
hard
{ "lang": "rust", "repo": "stevendanna/rust-memcache", "path": "/src/protocol/ascii.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aDotInTheVoid/noria path: /server/dataflow/src/node/process.rs use crate::node::NodeType; use crate::payload; use crate::prelude::*; use slog::Logger; use std::collections::HashSet; use std::mem; impl Node { #[allow(clippy::too_many_arguments)] pub(crate) fn process( &mut self, ...
code_fim
hard
{ "lang": "rust", "repo": "aDotInTheVoid/noria", "path": "/server/dataflow/src/node/process.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(new_last) = set_replay_last { if let Packet::ReplayPiece { context: payload::ReplayPieceContext::Regular { ref mut last }, .. } = **m { ...
code_fim
hard
{ "lang": "rust", "repo": "aDotInTheVoid/noria", "path": "/server/dataflow/src/node/process.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (data, replay) = match **m { Packet::ReplayPiece { tag, ref mut data, context: payload::ReplayPieceContext::Partial { ...
code_fim
hard
{ "lang": "rust", "repo": "aDotInTheVoid/noria", "path": "/server/dataflow/src/node/process.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> ShellCmdApi<'a> for Echo { cmd_api!(echo); // inserts boilerplate for command API fn process(&mut self, args: String::<1024>, _env: &mut CommonEnv) -> Result<Option<String::<1024>>, xous::Error> { Ok(Some(args)) } }<|fim_prefix|>// repo: betrusted-io/xous-core path: /service...
code_fim
easy
{ "lang": "rust", "repo": "betrusted-io/xous-core", "path": "/services/shellchat/src/cmds/echo.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: betrusted-io/xous-core path: /services/shellchat/src/cmds/echo.rs use crate::{ShellCmdApi, CommonEnv}; use xous_ipc::String; <|fim_suffix|> fn process(&mut self, args: String::<1024>, _env: &mut CommonEnv) -> Result<Option<String::<1024>>, xous::Error> { Ok(Some(args)) } }<|fim_m...
code_fim
medium
{ "lang": "rust", "repo": "betrusted-io/xous-core", "path": "/services/shellchat/src/cmds/echo.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let output_file_name: &OsStr = path.file_stem().unwrap(); let output_file_path = output_path.join(rel_path.with_file_name(output_file_name)); template::generate_template_with_processor_type( &processor, path, &output_file...
code_fim
hard
{ "lang": "rust", "repo": "forbjok/vut", "path": "/lib/src/project/generate_template.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forbjok/vut path: /lib/src/project/generate_template.rs use std::borrow::Cow; use std::ffi::OsStr; use std::path::{Path, PathBuf}; use tracing::debug; use crate::template::{self, TemplateInput}; use crate::util; use crate::version::{self, Version}; use super::{config, VutConfig, VutError}; #...
code_fim
hard
{ "lang": "rust", "repo": "forbjok/vut", "path": "/lib/src/project/generate_template.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Cow::Owned(start_path) } else { Cow::Borrowed(root_path) }; let output_path: Cow<Path> = if let Some(output_path) = &def.output_path { if output_path.is_absolute() { return Err(VutError::Config(Cow::Borrowed("Output path must be ...
code_fim
hard
{ "lang": "rust", "repo": "forbjok/vut", "path": "/lib/src/project/generate_template.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut i = 0; let key_size = key.len(); while i + key_size < org.len() { // print!("{} ", quo); Self::decrypt_with_accord(&mut org[i..key_size + i], &key); i += key_size; } } #[allow(clippy::ptr_a...
code_fim
hard
{ "lang": "rust", "repo": "KaranLMungra/classical_ciphers", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KaranLMungra/classical_ciphers path: /src/lib.rs pub mod cipher { use rand::{Rng, thread_rng}; use rand::distributions::Uniform; use std::collections::HashMap; /// # Ciphers /// This crate is implementation of two main traditional ciphers. /// ## Shift Cipher /// - ...
code_fim
hard
{ "lang": "rust", "repo": "KaranLMungra/classical_ciphers", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mapbased/nebulet path: /src/memory/code.rs use x86_64::structures::paging::PageTableFlags; use core::mem; use wasm::runtime::instance::{Instance, VmCtx}; use wasm::runtime::Module; use memory::Region; use nabi::{Result, Error}; <|fim_suffix|> pub fn execute(&mut self) { l...
code_fim
hard
{ "lang": "rust", "repo": "mapbased/nebulet", "path": "/src/memory/code.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Code { pub fn new(module: Module, mut region: Region, instance: Instance, start_func: *const u8) -> Result<Self> { let flags = PageTableFlags::PRESENT | PageTableFlags::GLOBAL; region.remap(flags)?; Ok(Code { module, instance, r...
code_fim
medium
{ "lang": "rust", "repo": "mapbased/nebulet", "path": "/src/memory/code.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wasmerio/cranelift path: /cranelift-codegen/meta/src/cdsl/ast.rs ar") } pub fn to_rust_code(&self, var_pool: &VarPool) -> String { match self { Expr::Var(var_index) => var_pool.get(*var_index).to_rust_code(), Expr::Literal(literal) => literal.to_rust_code...
code_fim
hard
{ "lang": "rust", "repo": "wasmerio/cranelift", "path": "/cranelift-codegen/meta/src/cdsl/ast.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wasmerio/cranelift path: /cranelift-codegen/meta/src/cdsl/ast.rs Expr::Literal(lit) => Some(lit), _ => None, } } pub fn maybe_var(&self) -> Option<VarIndex> { if let Expr::Var(var) = &self { Some(*var) } else { None } ...
code_fim
hard
{ "lang": "rust", "repo": "wasmerio/cranelift", "path": "/cranelift-codegen/meta/src/cdsl/ast.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>pub struct VarPool { pool: PrimaryMap<VarIndex, Var>, } impl VarPool { pub fn new() -> Self { Self { pool: PrimaryMap::new(), } } pub fn get(&self, index: VarIndex) -> &Var { self.pool.get(index).unwrap() } pub fn get_mut(&mut self, index: VarIn...
code_fim
hard
{ "lang": "rust", "repo": "wasmerio/cranelift", "path": "/cranelift-codegen/meta/src/cdsl/ast.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> /// Forwards an event to the `InputMethodEditorClient`, by sending a state update that makes no /// changes alongside a `KeyboardEvent`. Note that this state update will always have no changes /// — if you'd like to send a change, use `inject_input()`. pub(crate) async fn forward_event(&se...
code_fim
hard
{ "lang": "rust", "repo": "mvanotti/fuchsia-mirror", "path": "/src/ui/bin/text/src/legacy_ime/handler.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mvanotti/fuchsia-mirror path: /src/ui/bin/text/src/legacy_ime/handler.rs _input()` is called with a `KeyboardEvent`, `LegacyIme` contains an implementation /// of a QWERTY latin keyboard input method, and will send the appropriate edits to the text field. /// This can also handle arrow keys with...
code_fim
hard
{ "lang": "rust", "repo": "mvanotti/fuchsia-mirror", "path": "/src/ui/bin/text/src/legacy_ime/handler.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if keyboard_event.phase == uii::KeyboardEventPhase::Pressed || keyboard_event.phase == uii::KeyboardEventPhase::Repeat { if keyboard_event.code_point != 0 { state.type_keycode(keyboard_event.code_point); state.increment_revision(true)...
code_fim
hard
{ "lang": "rust", "repo": "mvanotti/fuchsia-mirror", "path": "/src/ui/bin/text/src/legacy_ime/handler.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> Returns a new bin that is the same dimensions as the original bin, but without any items. ```rust use bin_packer_3d::bin::Bin; use bin_packer_3d::item::{Item, ItemId}; let bin = Bin::new([24.0, 10.0, 4.0]); let new_bin = bin.clone_as_empty_bin(); ``` **/ ...
code_fim
hard
{ "lang": "rust", "repo": "data-twister/bin_packer_3d", "path": "/src/bin.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ```rust use bin_packer_3d::bin::Bin; use bin_packer_3d::item::{Item, ItemId}; let bin = Bin::new([24.0, 10.0, 4.0]); let new_bin = bin.clone_as_empty_bin(); ``` **/ pub fn clone_as_empty_bin(&self) -> Self { Self { blocks: self.blocks.clo...
code_fim
hard
{ "lang": "rust", "repo": "data-twister/bin_packer_3d", "path": "/src/bin.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: data-twister/bin_packer_3d path: /src/bin.rs use crate::block::{Block, Dimension}; use crate::item::Item; /// Represents an bin that a user can insert items into. /// ```rust /// use bin_packer_3d::bin::Bin; /// let bin = Bin::new([1.0, 2.0, 3.0]); /// ``` #[derive(Clone, Debug)] pub struct Bi...
code_fim
hard
{ "lang": "rust", "repo": "data-twister/bin_packer_3d", "path": "/src/bin.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/serde/src/ser/mod.rs /// period. /// /// For example, a filesystem [`Path`] may refuse to serialize /// itself if it contains invalid UTF-8 data. /// /// ```edition2018 ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/serde/src/ser/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/serde/src/ser/mod.rs SON data format. /// /// [example data format]: https://serde.rs/data-format.html pub trait Error: Sized $(+ $($supertrait)::+)* { /// Used when a [`Serialize`] implementation enco...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/serde/src/ser/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<Message>, RsocksError> { match parse_message(buf) { Ok((_i, msg)) => Ok(Some(msg)), Err(e) => Err(parser_error(format!("parse_message, {:?}", e))), } } } impl Encoder<Message> for MessageCodec { ...
code_fim
medium
{ "lang": "rust", "repo": "zzzdong/rsocks", "path": "/src/codecs/dns.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zzzdong/rsocks path: /src/codecs/dns.rs use bytes::BytesMut; use tokio_util::codec::*; use crate::errors::{parser_error, RsocksError}; use crate::parser::dns::*; use crate::proto::dns::Message; use crate::proto::WriteBuf; #[derive(Debug)] pub struct MessageCodec; impl Decoder for MessageCodec...
code_fim
hard
{ "lang": "rust", "repo": "zzzdong/rsocks", "path": "/src/codecs/dns.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SymbioticLab/Kayak path: /net/framework/src/shared_state/mod.rs /// Shareable data structures. pub mod directory; pub use self::shared_vec::*; mod shared_vec; use libc::{self, c_void, close, ftruncate, mmap, munmap, shm_open, shm_unlink}; use std::ffi::CString; use std::io::Error; use std::ptr; ...
code_fim
hard
{ "lang": "rust", "repo": "SymbioticLab/Kayak", "path": "/net/framework/src/shared_state/mod.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>unsafe fn open_shared<T>(name: &str, size: usize) -> SharedMemory<T> { // Make sure size is page aligned assert!(size & !PAGE_SIZE == 0); let name = CString::new(name).unwrap(); let mut fd = shm_open( name.as_ptr(), libc::O_CREAT | libc::O_EXCL | libc::O_RDWR, 0o700...
code_fim
hard
{ "lang": "rust", "repo": "SymbioticLab/Kayak", "path": "/net/framework/src/shared_state/mod.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aschampion/heraclitus path: /src/util.rs pub mod petgraph { use heraclitus_core::petgraph; use petgraph::prelude::*; use petgraph::Direction; use petgraph::visit::{ Data, GraphBase, GraphRef, IntoEdgesDirected, IntoNeighborsDirected, ...
code_fim
hard
{ "lang": "rust", "repo": "aschampion/heraclitus", "path": "/src/util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // TODO: Doesn't work with induced stream because reverses whole // graph. Not needed for now anyway since all our graphs are known // to be DAGs. // dfs.reset(g); // for &i in &finish_stack { // dfs.move_to(i); // ...
code_fim
hard
{ "lang": "rust", "repo": "aschampion/heraclitus", "path": "/src/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(<MersenneNumber<U7> as IsPrime>::Output::to_bool()); // 127 assert!(<MersenneNumber<U13> as IsPrime>::Output::to_bool()); // 8_191 assert!(<MersenneNumber<U17> as IsPrime>::Output::to_bool()); // 131_071 assert!(<MersenneNumber<U19> as IsPrime>::Output::to_bool()); // 524_287 /...
code_fim
medium
{ "lang": "rust", "repo": "dcrewi/typenum-prime-rs", "path": "/tests/larger_primes.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }