text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> if self.is_mut_borrowed(r) { return Err(GuestError::PtrBorrowed(r)); } let h = self.new_handle()?; self.shared_borrows.insert(h, r); Ok(h) } fn mut_borrow(&mut self, r: Region) -> Result<BorrowHandle, GuestError> { if self.is_shared_borr...
code_fim
hard
{ "lang": "rust", "repo": "kateinoigakukun/wasminspect", "path": "/crates/wasi/src/borrow.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kateinoigakukun/wasminspect path: /crates/wasi/src/borrow.rs /// Taken from https://github.com/bytecodealliance/wasmtime/blob/main/crates/wiggle/borrow/src/lib.rs /// Wasmtime is distributed under Apache License use std::cell::RefCell; use std::collections::HashMap; use wiggle::{BorrowHandle, Gu...
code_fim
hard
{ "lang": "rust", "repo": "kateinoigakukun/wasminspect", "path": "/crates/wasi/src/borrow.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn mut_borrow(&mut self, r: Region) -> Result<BorrowHandle, GuestError> { if self.is_shared_borrowed(r) || self.is_mut_borrowed(r) { return Err(GuestError::PtrBorrowed(r)); } let h = self.new_handle()?; self.mut_borrows.insert(h, r); Ok(h) } ...
code_fim
hard
{ "lang": "rust", "repo": "kateinoigakukun/wasminspect", "path": "/crates/wasi/src/borrow.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Expression { /// Two functions where local expressions have different IDs are usually not /// considered equal. This method normalizes expressions by replacing all /// locally defined IDs. fn normalize(&mut self) { let mut generator = IdGenerator::start_at( self.ca...
code_fim
hard
{ "lang": "rust", "repo": "candy-lang/candy", "path": "/compiler/frontend/src/mir_optimize/common_subtree_elimination.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Expression::Function { original_hirs, body, .. } = self { original_hirs.clear(); for (_, expression) in body.iter_mut() { expression.strip_original_hirs(); } } } } impl Body ...
code_fim
hard
{ "lang": "rust", "repo": "candy-lang/candy", "path": "/compiler/frontend/src/mir_optimize/common_subtree_elimination.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: candy-lang/candy path: /compiler/frontend/src/mir_optimize/common_subtree_elimination.rs //! Common subtree elimination deduplicates pure expressions that yield the same //! value. //! //! Here's a before-and-after example: //! //! ```mir //! $0 = builtinIntAdd | $0 = builtinIntAdd //! $1...
code_fim
hard
{ "lang": "rust", "repo": "candy-lang/candy", "path": "/compiler/frontend/src/mir_optimize/common_subtree_elimination.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kschat/advent-of-code-2020 path: /src/d10.rs use cached::proc_macro::cached; use crate::errors::AppResult; const INPUT: &'static str = include_str!("../data/jolts-adapters.txt"); fn calculate_jolt_difference(adapters: &[u16]) -> u16 { <|fim_suffix|> adapters.push(0); adapters.sort(); ...
code_fim
hard
{ "lang": "rust", "repo": "kschat/advent-of-code-2020", "path": "/src/d10.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("Part 1: \"{}\"", calculate_jolt_difference(&adapters)); let part2 = calculate_permutation_count( adapters.iter().map(|&x| x as u64).collect::<Vec<_>>(), outlet_jolts as u64, ); println!("Part 2: \"{}\"", part2); Ok(()) }<|fim_prefix|>// repo: kschat/advent-...
code_fim
hard
{ "lang": "rust", "repo": "kschat/advent-of-code-2020", "path": "/src/d10.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let dataset = &mut MnistImage::new(mnist_images, mnist_labels).unwrap(); let test_dataset = &mut MnistImage::new(test_mnist_images, test_mnist_labels).unwrap(); let mut network = NeuralNetwork::new(&[784, 100, 10]); network.stochastic_gradient_descend(100, 10, 3.0, dataset, test_dataset);...
code_fim
hard
{ "lang": "rust", "repo": "fineconstant/mnist_classification", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fineconstant/mnist_classification path: /src/main.rs use log::*; use mnist_classification::infrastructure::logging; use mnist_classification::infrastructure::mnist_loader::dataset::MnistImage; use mnist_classification::infrastructure::mnist_loader::*; use mnist_classification::prelude::NeuralNe...
code_fim
hard
{ "lang": "rust", "repo": "fineconstant/mnist_classification", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> logging::init(); let images_path = "resources/train-images-idx3-ubyte.gz"; let labels_path = "resources/train-labels-idx1-ubyte.gz"; let test_images_path = "resources/t10k-images-idx3-ubyte.gz"; let test_labels_path = "resources/t10k-labels-idx1-ubyte.gz"; let mnist_images = Mnist...
code_fim
medium
{ "lang": "rust", "repo": "fineconstant/mnist_classification", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> event_loop.poll_events(|ev| { use glium::glutin::{Event, WindowEvent}; match ev { Event::WindowEvent { event, .. } => match event { WindowEvent::Closed => running = false, _ => (), } _ => (), } }); } }<|fim_prefix|>// repo: twh2898/nestv3 path: /examples/image.rs exte...
code_fim
hard
{ "lang": "rust", "repo": "twh2898/nestv3", "path": "/examples/image.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: twh2898/nestv3 path: /examples/image.rs extern crate glium; use glium::glutin; extern crate nestv3; use nestv3::*; fn main() { let mut event_loop = glutin::EventsLoop::new(); let app = Window::new("Image Example", 640, 480, &event_loop).unwrap().with_dim_mode(DimensionMode::Scaled); let img...
code_fim
hard
{ "lang": "rust", "repo": "twh2898/nestv3", "path": "/examples/image.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match ev { Event::WindowEvent { event, .. } => match event { WindowEvent::Closed => running = false, _ => (), } _ => (), } }); } }<|fim_prefix|>// repo: twh2898/nestv3 path: /examples/image.rs extern crate glium; use glium::glutin; extern crate nestv3; use nestv3::*; fn m...
code_fim
medium
{ "lang": "rust", "repo": "twh2898/nestv3", "path": "/examples/image.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn try_exchange_rates_from_request(other: ExchangeRatesRequest) -> Result<ExchangeRates, CurrencyConversionError> { other .into_iter() .map(|(stq_rate_currency, stq_rate)| { Currency::try_from_stq_currency(stq_rate_currency) .map_err(|_| CurrencyConversi...
code_fim
medium
{ "lang": "rust", "repo": "SINHASantos/billing", "path": "/src/client/stores/types.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SINHASantos/billing path: /src/client/stores/types.rs use std::collections::HashMap; use stq_static_resources::Currency as StqCurrency; use stq_types::{CurrencyExchangeId, ExchangeRate}; use models::{currency::ConversionError as CurrencyConversionError, Currency}; pub type ExchangeRatesReques...
code_fim
medium
{ "lang": "rust", "repo": "SINHASantos/billing", "path": "/src/client/stores/types.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let ::std::option::Option::Some(ref v) = self.content { match v { &InnerMessage_oneof_content::RawBytes(ref v) => { os.write_bytes(1, v)?; }, &InnerMessage_oneof_content::Request(ref v) => { os.w...
code_fim
hard
{ "lang": "rust", "repo": "luqz/cita-common", "path": "/libproto/src/protos/communication.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luqz/cita-common path: /libproto/src/protos/communication.rs e(InnerMessage_oneof_content::Block(..)) => true, _ => false, } } // Param is passed by value, moved pub fn set_Block(&mut self, v: super::blockchain::Block) { self.content = ::std::option::Opti...
code_fim
hard
{ "lang": "rust", "repo": "luqz/cita-common", "path": "/libproto/src/protos/communication.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // .SnapshotReq SnapshotReq = 20; pub fn clear_SnapshotReq(&mut self) { self.content = ::std::option::Option::None; } pub fn has_SnapshotReq(&self) -> bool { match self.content { ::std::option::Option::Some(InnerMessage_oneof_content::SnapshotReq(..)) => true,...
code_fim
hard
{ "lang": "rust", "repo": "luqz/cita-common", "path": "/libproto/src/protos/communication.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn mdns_group() -> IpAddr; fn join_multicast(socket: &Socket) -> io::Result<()>; fn v6() -> bool; } impl AddressFamily for Inet { fn socket_builder() -> io::Result<Socket> { Socket::new(Domain::ipv4(), Type::dgram(), Some(Protocol::udp())) } fn any_addr() -> IpAddr { ...
code_fim
hard
{ "lang": "rust", "repo": "lrbalt/libmdns", "path": "/src/address_family.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lrbalt/libmdns path: /src/address_family.rs use super::MDNS_PORT; use socket2::{Domain, Protocol, SockAddr, Socket, Type}; use std::io; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, UdpSocket}; pub enum Inet {} pub enum Inet6 {} pub trait AddressFamily { fn bind() -> io::Result<Ud...
code_fim
hard
{ "lang": "rust", "repo": "lrbalt/libmdns", "path": "/src/address_family.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for (tickets, expected) in test_cases { assert_eq!( S::find_itinerary( tickets .iter() .map(|&[from, to]| vec![from.to_string(), to.to_string()]) .collect() ), ...
code_fim
hard
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_0332_reconstruct_itinerary/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0332_reconstruct_itinerary/mod.rs pub mod dfs; pub mod dfs_2; pub mod dfs_3; pub trait Solution { fn find_itinerary(tickets: Vec<Vec<String>>) -> Vec<String>; <|fim_suffix|> pub fn run<S: Solution>() { let test_cases = [ ( ...
code_fim
hard
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_0332_reconstruct_itinerary/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: redirectionio/libredirectionio path: /src/api/header.rs use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Header { <|fim_suffix|> pub name: String, pub value: Option<String>, }<|fim_middle|> #[serde(rename = "type")] pub kind: String,
code_fim
easy
{ "lang": "rust", "repo": "redirectionio/libredirectionio", "path": "/src/api/header.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub name: String, pub value: Option<String>, }<|fim_prefix|>// repo: redirectionio/libredirectionio path: /src/api/header.rs use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Header { <|fim_middle|> #[serde(rename = "type")] pub kind: String,
code_fim
easy
{ "lang": "rust", "repo": "redirectionio/libredirectionio", "path": "/src/api/header.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Get the current height of the chain /// /// # Example /// /// ``` /// ///use xpx_chain_sdk::api::SiriusClient; /// ///#[tokio::main] ///async fn main() { /// let node_url = vec!["http://bctestnet1.brimstone.xpxsirius.io:3000"]; /// let client = SiriusCli...
code_fim
hard
{ "lang": "rust", "repo": "proximax-storage/rust-xpx-chain-sdk", "path": "/src/api/routes/chain_routes_api.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: proximax-storage/rust-xpx-chain-sdk path: /src/api/routes/chain_routes_api.rs /* * Copyright 2018 ProximaX Limited. All rights reserved. * Use of this source code is governed by the Apache 2.0 * license that can be found in the LICENSE file. */ use {::std::sync::Arc, reqwest::Method}; use ...
code_fim
hard
{ "lang": "rust", "repo": "proximax-storage/rust-xpx-chain-sdk", "path": "/src/api/routes/chain_routes_api.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/futures-rs path: /futures-channel/tests/mpsc-close.rs use futures::channel::mpsc; use futures::executor::block_on; use futures::future::Future; use futures::sink::SinkExt; use futures::stream::StreamExt; use futures::task::{Context, Poll}; use std::pin::Pin; use std::sync::{Arc, Weak};...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/futures-rs", "path": "/futures-channel/tests/mpsc-close.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: move-z/adventofcode2018 path: /src/bin/day12.rs use adventofcode2018::*; use std::collections::HashMap; fn first(initial: &str, rules: &HashMap<&str, char>) -> isize { let mut current = String::from(initial); let mut start_idx = 0; for _ in 1..=20 { if !current.starts_with...
code_fim
hard
{ "lang": "rust", "repo": "move-z/adventofcode2018", "path": "/src/bin/day12.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod test { use super::*; #[test] fn test() { let mut rules = HashMap::new(); rules.insert("...##", '#'); rules.insert("..#..", '#'); rules.insert(".#...", '#'); rules.insert(".#.#.", '#'); rules.insert(".#.##", '#'); rules.i...
code_fim
hard
{ "lang": "rust", "repo": "move-z/adventofcode2018", "path": "/src/bin/day12.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: UTKARSH4/Snippets path: /rust/gist/biterator/src/main.rs use std::collections::HashMap; use std::io::Read; use std::env; use std::io; use std::fs::File; use std::str; use std::io::BufReader; use memmap::MmapOptions; fn main() -> io::Result<()> { let args: Vec<String> = env::args().collect(...
code_fim
hard
{ "lang": "rust", "repo": "UTKARSH4/Snippets", "path": "/rust/gist/biterator/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..10 { //seen = 0; // Avoid indexing for speed : https://llogiq.github.io/2017/06/01/perf-pitfalls.html for tmp in data.iter() { seen += 1; sum += *tmp as u64; // The speed is _so_ much faster without freq freq[*tmp as ...
code_fim
hard
{ "lang": "rust", "repo": "UTKARSH4/Snippets", "path": "/rust/gist/biterator/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let data = util::lines_from_file_as_u32("./data/day1.txt"); assert_eq!(1007104, part1(data).unwrap()) } #[test] fn d1part2test() { let data = util::lines_from_file_as_u32("./data/day1.txt"); assert_eq!(18847752, part2(data).unwrap()) } }<|fim_prefix|>// rep...
code_fim
hard
{ "lang": "rust", "repo": "finleygn/adventofcode2020", "path": "/src/days/day01.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: finleygn/adventofcode2020 path: /src/days/day01.rs // Probably should've done this https://en.wikipedia.org/wiki/3SUM pub fn part1(data: Vec<u32>) -> Result<u32, ()> { for i in 0..data.len() { for ii in 0..data.len() { let inum = data[i]; let iinum = data[ii]...
code_fim
hard
{ "lang": "rust", "repo": "finleygn/adventofcode2020", "path": "/src/days/day01.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let vbox = Box::new(gtk::Orientation::Vertical, 0); if let Some(title) = &asset_info.title { let name = Label::new(None); name.set_markup(&format!("<b><u><big>{}</big></u></b>", title)); name.s...
code_fim
hard
{ "lang": "rust", "repo": "fjardon/Epic-Asset-Manager", "path": "/src/ui/assets.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fjardon/Epic-Asset-Manager path: /src/ui/assets.rs use crate::tools::asset_info::Search; use crate::Win; use egs_api::api::types::asset_info::AssetInfo; use glib::Cast; use gtk::gdk_pixbuf::traits::PixbufLoaderExt; use gtk::traits::{ ButtonExt, ContainerExt, EntryExt, FlowBoxExt, GridExt, Im...
code_fim
hard
{ "lang": "rust", "repo": "fjardon/Epic-Asset-Manager", "path": "/src/ui/assets.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if !self.widgets.details_revealer.reveals_child() { self.widgets.details_revealer.set_reveal_child(true); } } } } } fn close_asset_details(&mut self) { self.widgets.download_button.set_sens...
code_fim
hard
{ "lang": "rust", "repo": "fjardon/Epic-Asset-Manager", "path": "/src/ui/assets.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl MsaAggregateQueryRequest { pub fn new(date_ranges: Vec<crate::models::MsaDateRangeSpec>, field: String, filter: String, interval: String, min_doc_count: i64, missing: String, name: String, q: String, ranges: Vec<crate::models::MsaRangeSpec>, size: i32, sort: String, sub_aggregates: Vec<crate::mod...
code_fim
hard
{ "lang": "rust", "repo": "jshcodes/falcon-rs", "path": "/src/models/msa_aggregate_query_request.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jshcodes/falcon-rs path: /src/models/msa_aggregate_query_request.rs /* * CrowdStrike API Specification * * Use this API specification as a reference for the API endpoints you can use to interact with your Falcon environment. These endpoints support authentication via OAuth2 and interact with ...
code_fim
hard
{ "lang": "rust", "repo": "jshcodes/falcon-rs", "path": "/src/models/msa_aggregate_query_request.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rome/tools path: /crates/rome_rowan/src/green/token.rs use std::{ borrow::Borrow, fmt, mem::{self, ManuallyDrop}, ops, ptr, }; use countme::Count; use crate::green::trivia::GreenTrivia; use crate::{ arc::{Arc, HeaderSlice, ThinArc}, green::RawSyntaxKind, TextSize, }...
code_fim
hard
{ "lang": "rust", "repo": "rome/tools", "path": "/crates/rome_rowan/src/green/token.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let start: usize = leading_len.into(); let end: usize = (total_len - trailing_len).into(); let text = unsafe { std::str::from_utf8_unchecked(self.data.slice()) }; &text[start..end] } /// Returns the length of the text covered by this token. #[inline] pub fn...
code_fim
hard
{ "lang": "rust", "repo": "rome/tools", "path": "/crates/rome_rowan/src/green/token.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn leading_trailing_total_len(&self) -> (TextSize, TextSize, TextSize) { let leading_len = self.data.header.leading.text_len(); let trailing_len = self.data.header.trailing.text_len(); let total_len = self.data.slice().len() as u32; (leading_len, trailing_len...
code_fim
hard
{ "lang": "rust", "repo": "rome/tools", "path": "/crates/rome_rowan/src/green/token.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub const DDSPF_A8: PixelFormat = PixelFormat::raw(DDS_ALPHA, 8, 0x00, 0x00, 0x00, 0xff); pub const DDSPF_L8: PixelFormat = PixelFormat::raw(DDS_LUMINANCE, 8, 0xff, 0x00, 0x00, 0x00); pub const DDSPF_R5G6B5: PixelFormat = PixelFormat::raw(DDS_RGB, 16, 0xf800, 0x07e0, 0x001f, 0x0000); pub const DDSPF_A1R5G...
code_fim
hard
{ "lang": "rust", "repo": "PlatinumTeam/MBExtender", "path": "/MBExtender/rust/speed-boostair/src/dds_types.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PlatinumTeam/MBExtender path: /MBExtender/rust/speed-boostair/src/dds_types.rs use std::mem; pub const DDS_MAGIC: [u8; 4] = *b"DDS "; pub const DDS_ALPHA: u32 = 0x2; pub const DDS_FOURCC: u32 = 0x4; pub const DDS_RGB: u32 = 0x40; pub const DDS_RGBA: u32 = 0x41; pub const DDS_LUMINANCE: u32 = 0...
code_fim
hard
{ "lang": "rust", "repo": "PlatinumTeam/MBExtender", "path": "/MBExtender/rust/speed-boostair/src/dds_types.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match (x, Some(1i32)) { (Ok(x), Some(_)) => println!("ok {}", x), (Ok(_), Some(x)) => println!("ok {}", x), _ => println!("err"), } // No warning; different types for `x`. match (x, Some(1.0f64)) { (Ok(x), Some(_)) => println!("ok {}", x), (Ok(_), S...
code_fim
hard
{ "lang": "rust", "repo": "mchlrhw/rust-clippy", "path": "/tests/ui/matches.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mchlrhw/rust-clippy path: /tests/ui/matches.rs #![feature(exclusive_range_pattern)] #![warn(clippy::all)] #![allow(unused, clippy::redundant_pattern_matching, clippy::too_many_lines)] #![warn(clippy::match_same_arms)] fn dummy() {} fn match_wild_err_arm() { let x: Result<i32, &str> = Ok(3)...
code_fim
hard
{ "lang": "rust", "repo": "mchlrhw/rust-clippy", "path": "/tests/ui/matches.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> tilecount: u32, tileheight: u32, tilewidth: u32, columns: u32, image: PathBuf, imageheight: u32, imagewidth: u32, margin: u32, spacing: u32, properties: Option<HashMap<String, String>>, terrains: Option<Vec<Terrain>>, tileproperties: T...
code_fim
hard
{ "lang": "rust", "repo": "martinlindhe/tiled-json", "path": "/src/tileset.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Deserialize for TileProperties { fn deserialize<D: Deserializer>(d: &mut D) -> Result<Self, D::Error> { // Tiled uses string keys because it's a sparse array, // so we're just going to parse it like that and then // convert them to LocalTiles let data: HashMap...
code_fim
hard
{ "lang": "rust", "repo": "martinlindhe/tiled-json", "path": "/src/tileset.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: martinlindhe/tiled-json path: /src/tileset.rs use std::str; use std::path::PathBuf; use std::ffi::OsStr; use std::fs::File; use std::collections::HashMap; use {GlobalTile, LocalTile}; use serde::{Deserialize, Deserializer}; use serde_json; use serde_json::Value as JsonValue; use s...
code_fim
hard
{ "lang": "rust", "repo": "martinlindhe/tiled-json", "path": "/src/tileset.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> b.iter(|| { let file = File::open("README").expect("failed"); let mut f2 = BufReader::new(file); f2.seek(io::SeekFrom::Start(IDX as u64)); let mut v1 = [0;1000]; f2.read_exact(&mut v1); f2.seek(io::SeekFrom::Start(0)); ...
code_fim
hard
{ "lang": "rust", "repo": "ganmacs/playground", "path": "/rust/bench/src/mmmap.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; use test::Bencher; #[bench] fn b1(b: &mut Bencher) { b.iter(|| { let file = File::open("README").expect("failed"); let f = unsafe { MmapOptions::new().map(&file).expect("memmap failed") }; let v1: &[u8] = &...
code_fim
medium
{ "lang": "rust", "repo": "ganmacs/playground", "path": "/rust/bench/src/mmmap.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ganmacs/playground path: /rust/bench/src/mmmap.rs use memmap::*; use std::io; use std::io::{Write, BufReader}; use std::fs::File; use std::io::Seek; use std::io::Read; const IDX: usize = 2^32; pub fn mmain() { open_file(); } fn open_file() { let file = File::open("README").expect("fai...
code_fim
hard
{ "lang": "rust", "repo": "ganmacs/playground", "path": "/rust/bench/src/mmmap.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} pub trait ToModel<'a, Model> { fn to_model(&'a self) -> Model; } #[derive(Deserialize, Debug)] pub struct SearchQuery<'a> { pub value: &'a str, }<|fim_prefix|>// repo: oknozor/froovie path: /src/dtos/mod.rs pub mod movies; pub mod user_selections; pub mod users; use serde::{Deserialize, Ser...
code_fim
medium
{ "lang": "rust", "repo": "oknozor/froovie", "path": "/src/dtos/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} #[derive(Deserialize, Debug)] pub struct SearchQuery<'a> { pub value: &'a str, }<|fim_prefix|>// repo: oknozor/froovie path: /src/dtos/mod.rs pub mod movies; pub mod user_selections; pub mod users; use serde::{Deserialize, Serialize}; pub trait FromModel<Model> { fn from_model(id: i32) -> ...
code_fim
medium
{ "lang": "rust", "repo": "oknozor/froovie", "path": "/src/dtos/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oknozor/froovie path: /src/dtos/mod.rs pub mod movies; pub mod user_selections; pub mod users; use serde::{Deserialize, Serialize}; <|fim_suffix|>} #[derive(Deserialize, Debug)] pub struct SearchQuery<'a> { pub value: &'a str, }<|fim_middle|>pub trait FromModel<Model> { fn from_mode...
code_fim
medium
{ "lang": "rust", "repo": "oknozor/froovie", "path": "/src/dtos/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Velfi/ca_play path: /src/utils.rs //use std::ops::Mul; //use std::ops::Add; pub fn map_t_of_range_a_to_range_b( t: f32, range_a_start: f32, range_a_end: f32, range_b_start: f32, range_b_end: f32, ) -> f32 { let slope = (range_b_end - range_b_start) / (range_a_end - range...
code_fim
medium
{ "lang": "rust", "repo": "Velfi/ca_play", "path": "/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_get_index_wrapping() { assert_eq!(0, get_index_wrapping(0, 10)); assert_eq!(0, get_index_wrapping(10, 10)); assert_eq!(5, get_index_wrapping(5, 10)); assert_eq!(9, get_index_wrapping(19, 10)); assert_eq!(0, get_index_wrapping(-10, 10)); }...
code_fim
hard
{ "lang": "rust", "repo": "Velfi/ca_play", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_get_right_neighbour_index_wrapping() { assert_eq!(1, get_right_neighbour_index_wrapping(0, 4)); assert_eq!(0, get_right_neighbour_index_wrapping(3, 4)); } #[test] fn test_get_left_neighbour_index_wrapping() { assert_eq!(2, get_left_neighbour_ind...
code_fim
hard
{ "lang": "rust", "repo": "Velfi/ca_play", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Leonqn/rutebot path: /examples/echobot.rs use std::env; use futures_util::StreamExt; use rutebot::{ client::Rutebot, requests::SendMessage, responses::{Message, Update}, }; use std::error::Error; <|fim_suffix|> let rutebot = Rutebot::new(token); let mut updates_stream = Box:...
code_fim
hard
{ "lang": "rust", "repo": "Leonqn/rutebot", "path": "/examples/echobot.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eth-p/joinerator path: /src/build.rs // ------------------------------------------------------------------------------------------------- // joinerator | Copyright (C) 2019 eth-p // This is a script that generates the cbor serde cache used for pre-parsing the YAML repertoires. // ---------------...
code_fim
medium
{ "lang": "rust", "repo": "eth-p/joinerator", "path": "/src/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if result.is_ok() { return (); } for cause in Error::iter_chain(&result.unwrap_err()) { eprintln!("{}: {}", cause.name().unwrap_or("Error"), cause); } panic!(); } fn build_cache() -> Result<(), Error> { let mut repertoires: HashMap<String, Repertoire> = HashMap::...
code_fim
medium
{ "lang": "rust", "repo": "eth-p/joinerator", "path": "/src/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>T_U, D2D_SIZE_F, D2D_SIZE_U, D2D_VECTOR_2F, D2D_VECTOR_3F, D2D_VECTOR_4F, }; pub type D2D_COLOR_F = D3DCOLORVALUE;<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/winapi/src/um/d2dbasetypes.rs use shared::d3d9types::D3DCOLORVALUE; pub use um::dcommon::{ D2D...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/winapi/src/um/d2dbasetypes.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/winapi/src/um/d2dbasetypes.rs use shared::d3d9types::D3DCOLORVALUE; pub use um::dcommon::{ D2D1_MATRIX_3X2_F, D2D1_POINT_2F, D2D1_POINT_2<|fim_suffix|>T_U, D2D_SIZE_F, D2D_SIZE_U, D2D_VECTOR_2F, D2D_VECTOR_3F, D2D_VECTOR_4...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/winapi/src/um/d2dbasetypes.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_as_string(){ let json_value = from_str("\"dog\"").unwrap(); let json_str = json_value.as_string(); let expected_str = "dog"; assert_eq!(json_str, Some(expected_str)); } #[test] fn test_is_number(){ let json_value = from_str("12").unwrap(); assert!(json_value.is_num...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/libserialize/tests/json.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let v: Vec<isize> = json::decode("[3, 1]").unwrap(); assert_eq!(v, [3, 1]); let v: Vec<Vec<usize>> = json::decode("[[3], [1, 2]]").unwrap(); assert_eq!(v, [vec![3], vec![1, 2]]); } #[test] fn test_decode_tuple() { let t: (usize, usize, usize) = json::decode("[1, 2, 3]").unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/libserialize/tests/json.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/libserialize/tests/json.rs rr(e) => { assert_eq!(e, expected); } } } #[test] fn test_decode_errors_struct() { check_err::<DecodeStruct>("[]", ExpectedError("Object".to_string(), "[]".to_string())); check_err::<DecodeStruc...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/libserialize/tests/json.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// get count of distanceses #[wasm_bindgen] pub fn float_vec_size(vec: *const Vec<OrderedFloat<f64>>) -> usize { if !vec.is_null() { unsafe { (*vec).len() } } else { 0 as usize } } /// get float object at index #[wasm_bindgen] pub fn float_vec_get( vec: *const Vec<Ordered...
code_fim
hard
{ "lang": "rust", "repo": "oc-soft/glrs", "path": "/src/wasm/float_vec.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oc-soft/glrs path: /src/wasm/float_vec.rs use super::float::*; use ordered_float::OrderedFloat; use std::rc::Rc; use wasm_bindgen::prelude::*; /// increment reference count #[wasm_bindgen] pub fn float_vec_retain(vec: *const Vec<OrderedFloat<f64>>) -> usize { unsafe { let vec_ref_0 ...
code_fim
hard
{ "lang": "rust", "repo": "oc-soft/glrs", "path": "/src/wasm/float_vec.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ichyo/icfpc2019-public path: /src/utils.rs use crate::models::Point; #[derive(Debug, Clone, Eq, PartialEq)] pub struct Matrix<T> { width: usize, height: usize, inner: Vec<T>, } impl<T: Clone> Matrix<T> { pub fn new(width: usize, height: usize, init: T) -> Matrix<T> { le...
code_fim
hard
{ "lang": "rust", "repo": "ichyo/icfpc2019-public", "path": "/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set(&mut self, p: Point, value: T) { if let Some(r) = self.get_mut(p) { *r = value; } else { panic!("out of bound : {:?}", p); } } } #[derive(Clone, Copy, Eq, PartialEq, Debug)] pub struct Range { pub start: usize, pub end: usize, } ...
code_fim
hard
{ "lang": "rust", "repo": "ichyo/icfpc2019-public", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>allow_tables_to_appear_in_same_query!(fixed_phrases, send_emails, users,);<|fim_prefix|>// repo: k-nasa/peco_api path: /src/schema.rs table! { fixed_phrases (id) { id -> Int4, user_id -> Int4, yes_text -> Text, no_text -> Text, } } <|fim_middle|>table! { send_...
code_fim
hard
{ "lang": "rust", "repo": "k-nasa/peco_api", "path": "/src/schema.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: k-nasa/peco_api path: /src/schema.rs table! { fixed_phrases (id) { id -> Int4, user_id -> Int4, yes_text -> Text, no_text -> Text, } } table! { send_emails (id) { id -> Int4, user_id -> Int4, email -> Text, } } <|fim_suffi...
code_fim
hard
{ "lang": "rust", "repo": "k-nasa/peco_api", "path": "/src/schema.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: neivv/mtl path: /src/ini.rs use std::io::{BufRead, BufReader, Read}; use std::mem; use anyhow::{anyhow, Error}; pub struct Ini { pub sections: Vec<Section>, } pub struct Section { pub name: String, pub values: Vec<(String, String)>, } impl Ini { pub fn open<R: Read>(file: R) ...
code_fim
hard
{ "lang": "rust", "repo": "neivv/mtl", "path": "/src/ini.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>[upgrade.15.level.3] ; Cannon units = 162 ; Tower attack state = order(0x13) hp_regen = 400 "###; let read = TEXT.as_bytes(); let ini = Ini::open(read).unwrap(); assert_eq!(ini.sections[0].name, "timers"); assert_eq!(ini.sections[1].name, "orders"); assert_eq!(ini.sections[2].name, "up...
code_fim
hard
{ "lang": "rust", "repo": "neivv/mtl", "path": "/src/ini.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>[upgrade.3.level.3] ; sunu units = 146 ; Default 15 creep_spread_timer = 1 [upgrade.15.level.1] ; Pylo units = 156 ; Note: Upgrade bonuses apply to completed units only if the state doesn't explicitly ; require incomplete state = incomplete shield_regen = 50 [upgrade.15.level.1] ; Cannon units = 162 sta...
code_fim
hard
{ "lang": "rust", "repo": "neivv/mtl", "path": "/src/ini.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-windowing/winit path: /src/platform_impl/linux/x11/util/icon.rs #![allow(clippy::assertions_on_constants)] use super::*; use crate::icon::{Icon, Pixel, PIXEL_SIZE}; impl Pixel { pub fn to_packed_argb(&self) -> Cardinal { let mut cardinal = 0; assert!(CARDINAL_SIZE >= P...
code_fim
hard
{ "lang": "rust", "repo": "rust-windowing/winit", "path": "/src/platform_impl/linux/x11/util/icon.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Cardinal); data.push(rgba_icon.height as Cardinal); let pixels = rgba_icon.rgba.as_ptr() as *const Pixel; for pixel_index in 0..pixel_count { let pixel = unsafe { &*pixels.add(pixel_index) }; data.push(pixel.to_packed_argb()); } data } }...
code_fim
hard
{ "lang": "rust", "repo": "rust-windowing/winit", "path": "/src/platform_impl/linux/x11/util/icon.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let model = Model::read_file("obj/floor.obj").unwrap(); let up = Vector3f::new(0.0, 1.0, 0.0); let light_dir = Vector3f::new(1.0, 1.0, 1.0); let center = Point3f::new(0.0, 0.0, 0.0); let mut buffer = Buffer::new(W, H); let cam = Camera::new(center, [0.0, -1.0, -1.0].into(), up, 4.0...
code_fim
hard
{ "lang": "rust", "repo": "dkeehl/rasterize", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dkeehl/rasterize path: /src/main.rs #![allow(unused)] use rasterizer::*; use rasterizer::model::Model; fn main() { // let img = floor(); // let img = shadow_test().view_z_buffer(); let img = head(); img.write_file("output.tga").unwrap(); // rasterizer::gui::view(W as u32, H ...
code_fim
hard
{ "lang": "rust", "repo": "dkeehl/rasterize", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simsekgokhan/carpe-old path: /src-tauri/src/commands/mod.rs mod wallets; mod swarm; mod mining; mod client; mod tx; pub use wallets::*; pub use swarm::*; pub use mining::*; pub use client::*; pub use tx::*; use diem_types::transaction::authenticator::AuthenticationKey; use miner::block::{ /...
code_fim
hard
{ "lang": "rust", "repo": "simsekgokhan/carpe-old", "path": "/src-tauri/src/commands/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let upstream = Url::try_from(UPSTREAM).ok(); if upstream.is_none(){ waypoint = MAINNET_GENESIS_WAYPOINT.parse().ok(); starting_epoch = Some(0); } // let path = PathBuf::from(path); ol_types::config::AppCfg::init_app_configs( key, acc, // TODO: how to pick a URL to fetch upst...
code_fim
hard
{ "lang": "rust", "repo": "simsekgokhan/carpe-old", "path": "/src-tauri/src/commands/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// Private modules used by multiple public modules. #[cfg(any(feature = "procfs", feature = "process", feature = "runtime"))] pub(crate) mod pid; #[cfg(any(feature = "process", feature = "thread"))] pub(crate) mod prctl; #[cfg(any( feature = "fs", feature = "process", feature = "thread", a...
code_fim
hard
{ "lang": "rust", "repo": "giodamelio/little_boxes", "path": "/vendor/rustix/src/backend/linux_raw/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: giodamelio/little_boxes path: /vendor/rustix/src/backend/linux_raw/mod.rs //! The linux_raw backend. //! //! This makes Linux syscalls directly, without going through libc. //! //! # Safety //! //! These files performs raw system calls, and sometimes passes them //! uninitialized memory buffers....
code_fim
hard
{ "lang": "rust", "repo": "giodamelio/little_boxes", "path": "/vendor/rustix/src/backend/linux_raw/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: inferiorhumanorgans/sam3x8e-fork path: /src/hsmci/sdcr.rs #[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::SDCR { #[doc = r" Modifies the contents of the register"] #[inline] ...
code_fim
hard
{ "lang": "rust", "repo": "inferiorhumanorgans/sam3x8e-fork", "path": "/src/hsmci/sdcr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>elf, variant: SDCBUSW) -> &'a mut W { unsafe { self.bits(variant._bits()) } } #[doc = "1 bit"] #[inline] pub fn _1(self) -> &'a mut W { self.variant(SDCBUSW::_1) } #[doc = "4 bits"] #[inline] pub fn _4(self) -> &'a mut W { self.variant(SDCBUSW::_4) ...
code_fim
hard
{ "lang": "rust", "repo": "inferiorhumanorgans/sam3x8e-fork", "path": "/src/hsmci/sdcr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>C_R::new(((self.bits >> 8) & 3) as u8) } #[doc = "Bits 12:13 - Input capture 1 filter This bitfield defines the number of consecutive equal samples that should be detected when a level change occurs on an external input capture signal before it is considered as a valid level transition. An interna...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h5/src/stm32h503/lptim1/ccmr1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32h5/src/stm32h503/lptim1/ccmr1.rs #[doc = "Register `CCMR1` reader"] pub type R = crate::R<CCMR1_SPEC>; #[doc = "Register `CCMR1` writer"] pub type W = crate::W<CCMR1_SPEC>; #[doc = "Field `CC1SEL` reader - Capture/compare 1 selection This bitfield defines ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h5/src/stm32h503/lptim1/ccmr1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (a, b) = (200, 200); // `u8` can hold values in range `0..255` // `400 > 255` -> overflow // Default compiler options -> panic // `-O` -> incorrect result of `144` let c: u8 = a + b; println!("200 + 200 = {}", c); }<|fim_prefix|>// repo: SteadBytes/study path: /rust-in-act...
code_fim
easy
{ "lang": "rust", "repo": "SteadBytes/study", "path": "/rust-in-action/ch05/impossible-addition.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SteadBytes/study path: /rust-in-action/ch05/impossible-addition.rs //! # Impossible Addition //! Integer overflow can also be triggered by mathematical operations which //! produce results that cannot fit into the target data type. <|fim_suffix|> let (a, b) = (200, 200); // `u8` can hold...
code_fim
easy
{ "lang": "rust", "repo": "SteadBytes/study", "path": "/rust-in-action/ch05/impossible-addition.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: olympusprotocol/olympus path: /pallets/AMM/src/default_weight.rs //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0 #![allow(unused_parens)] #![allow(unused_imports)] use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight}; <|fim_suffix|> (362...
code_fim
medium
{ "lang": "rust", "repo": "olympusprotocol/olympus", "path": "/pallets/AMM/src/default_weight.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> (414_245_000 as Weight) .saturating_add(DbWeight::get().reads(9 as Weight)) .saturating_add(DbWeight::get().writes(7 as Weight)) } fn swap_with_exact_supply() -> Weight { (409_297_000 as Weight) .saturating_add(DbWeight::get().reads(9 as Weight)) .saturating_add(DbWeight::get().writes(6 ...
code_fim
hard
{ "lang": "rust", "repo": "olympusprotocol/olympus", "path": "/pallets/AMM/src/default_weight.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> (409_297_000 as Weight) .saturating_add(DbWeight::get().reads(9 as Weight)) .saturating_add(DbWeight::get().writes(6 as Weight)) } }<|fim_prefix|>// repo: olympusprotocol/olympus path: /pallets/AMM/src/default_weight.rs //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2...
code_fim
hard
{ "lang": "rust", "repo": "olympusprotocol/olympus", "path": "/pallets/AMM/src/default_weight.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match *self { ContextError::Io(ref err) => Some(err), ContextError::__Unknown => unreachable!(), } } } impl From<io::Error> for ContextError { fn from(err: std::io::Error) -> Self { ContextError::Io(err) } } #[cfg(test)] mod tests { use sup...
code_fim
hard
{ "lang": "rust", "repo": "Pedrotojal/automaat", "path": "/src/core/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Pedrotojal/automaat path: /src/core/src/lib.rs //! # Automaat //! //! Automaat can help you automate mundane and repeated tasks in a flexible way. //! //! Its goal is to provide a simplified, user-friendly, and highly-customisable //! interface that combines "customer support" software, job sche...
code_fim
hard
{ "lang": "rust", "repo": "Pedrotojal/automaat", "path": "/src/core/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Script for KConfig { fn apply(&self, bridge: &Bridge) -> Result<()> { for assignment in &self.assignments { bridge .symbol(&assignment.symbol) .with_context(|| format!("could not get symbol {:?}", assignment.symbol))? .set_value_...
code_fim
hard
{ "lang": "rust", "repo": "oddlama/autokernel", "path": "/src/script/kconfig.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oddlama/autokernel path: /src/script/kconfig.rs use bridge::Bridge; use std::path::Path; use anyhow::anyhow; use anyhow::Context; use anyhow::Result; use crate::bridge; use super::Script; use std::fs; struct Assignment { symbol: String, value: String, line: usize, } <|fim_suffix...
code_fim
hard
{ "lang": "rust", "repo": "oddlama/autokernel", "path": "/src/script/kconfig.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn from_content(filename: String, content: String) -> Result<KConfig> { let mut assignments = Vec::new(); for (i, line) in content.lines().enumerate() { let line = line.trim(); if line.is_empty() || line.starts_with('#') { continue; ...
code_fim
medium
{ "lang": "rust", "repo": "oddlama/autokernel", "path": "/src/script/kconfig.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } } fn main() { let opcodes = parse_opcodes("input"); println!("2-1:"); println!("{:?}", run(&opcodes, (12, 2))); println!("2-2:"); for a in 0..99 { for b in 0..99 { if run(&opcodes, (a, b)) == 19690720 { println!("{}", 100 * a + b); ...
code_fim
hard
{ "lang": "rust", "repo": "tedle/Advent-of-Code-2019", "path": "/02/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tedle/Advent-of-Code-2019 path: /02/src/main.rs use std::fs; fn parse_opcodes(filename: &str) -> Vec<usize> { let input = fs::read_to_string(filename).unwrap(); input.split(",").map(|op| op.trim().parse().unwrap()).collect() } <|fim_suffix|> stack_pointer += 4; ...
code_fim
hard
{ "lang": "rust", "repo": "tedle/Advent-of-Code-2019", "path": "/02/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> stack_pointer += 4; opcodes[cx] = opcodes[ax] + opcodes[bx] }, 2 => { let ax = opcodes[stack_pointer+1]; let bx = opcodes[stack_pointer+2]; let cx = opcodes[stack_pointer+3]; stack_poin...
code_fim
hard
{ "lang": "rust", "repo": "tedle/Advent-of-Code-2019", "path": "/02/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }