text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: toyatech/embedded-radio path: /src/helpers.rs //! Provides common helpers for implementing radio utilities //! //! ## https://github.com/ryankurte/rust-radio //! ## Copyright 2020 Ryan Kurte use structopt::StructOpt; use humantime::{Duration as HumanDuration}; use embedded_hal::blocking::delay...
code_fim
hard
{ "lang": "rust", "repo": "toyatech/embedded-radio", "path": "/src/helpers.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Parse RSSI and other info from response messages /// (echo server must have --append-info set) #[structopt(long)] pub parse_info: bool, #[structopt(flatten)] pub blocking_options: BlockingOptions, } pub struct LinkTestInfo { pub sent: u32, pub received: u32, pub l...
code_fim
hard
{ "lang": "rust", "repo": "toyatech/embedded-radio", "path": "/src/helpers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>he time acquired by the entity each turn. pub speed: i32, }<|fim_prefix|>// repo: ndouglas/azymus path: /src/component/actor/mod.rs /// Something that gets dispensed time and has an opportunity <|fim_middle|>to act. #[derive(Clone, Copy, Debug)] pub struct Actor { /// The current time of the enti...
code_fim
medium
{ "lang": "rust", "repo": "ndouglas/azymus", "path": "/src/component/actor/mod.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ndouglas/azymus path: /src/component/actor/mod.rs /// Something that gets dispensed time and has an opportunity <|fim_suffix|>/ The current time of the entity. pub time: i32, /// The time acquired by the entity each turn. pub speed: i32, }<|fim_middle|>to act. #[derive(Clone, Copy, D...
code_fim
medium
{ "lang": "rust", "repo": "ndouglas/azymus", "path": "/src/component/actor/mod.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>struct Storage(Arc<dyn KeyValueDB>); impl sp_state_machine::Storage<sp_core::Blake2Hasher> for Storage { fn get(&self, key: &Hash, prefix: Prefix) -> Result<Option<Vec<u8>>, String> { let key = sp_trie::prefixed_key::<sp_core::Blake2Hasher>(key, prefix); self.0.get(0, &key).map_err(|e| format!("Data...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/bin/node/bench/src/trie.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl core::Benchmark for TrieReadBenchmark { fn run(&mut self, mode: Mode) -> std::time::Duration { let mut db = self.database.clone(); let storage: Arc<dyn sp_state_machine::Storage<sp_core::Blake2Hasher>> = Arc::new(Storage(db.open(self.database_type))); let trie_backend = sp_state_machine::...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/bin/node/bench/src/trie.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paritytech/substrate path: /bin/node/bench/src/trie.rs // This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 // This program is free software: you can redistribute it and/or modify // it under...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/bin/node/bench/src/trie.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /src/Windows/Win32/Security/Authentication/Identity/Provider/mod.rs m_Com_StructuredStorage", feature = "Win32_UI_Shell_PropertiesSystem"))] pub unsafe fn Begin_EnumerateIdentities(&self, eidentitytype: IDENTITY_TYPE, pfilterkey: *const super::super::super::...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/src/Windows/Win32/Security/Authentication/Identity/Provider/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for AsyncIConnectedIdentityProvider { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Owned(self.0) } } impl<'a> ::windows::core::IntoPa...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/src/Windows/Win32/Security/Authentication/Identity/Provider/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: therahulkanyal/funky path: /ifds/src/icfg/graph.rs #![allow(dead_code)] use anyhow::Result; use itertools::Itertools; type VarId = String; type FunctionName = String; /// The datastructure for the graph. #[derive(Debug, Default, Clone)] pub struct Graph { pub edges: Vec<Edge>, } impl Gra...
code_fim
hard
{ "lang": "rust", "repo": "therahulkanyal/funky", "path": "/ifds/src/icfg/graph.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Fact { /// Build a new fact from a given variable pub fn from_var(var: &Variable, pc: usize, next_pc: usize, track: usize) -> Fact { Fact { belongs_to_var: var.name.clone(), function: var.function.clone(), pc, next_pc, track,...
code_fim
hard
{ "lang": "rust", "repo": "therahulkanyal/funky", "path": "/ifds/src/icfg/graph.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Iterate over all functions of the contract in arbitrary order. pub fn functions<'a>(&'a self) -> Box<Iterator<Item = Function> + 'a> { let iter = self.functions.values().cloned(); Box::new(iter) } /// Iterate over all events of the contract in arbitrary order. pub ...
code_fim
hard
{ "lang": "rust", "repo": "eira-fransham/ethabi", "path": "/src/contract.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eira-fransham/ethabi path: /src/contract.rs use std::collections::HashMap; use spec::{Interface, Operation}; use function::Function; use constructor::Constructor; use event::Event; use error::Error; /// API building calls to contracts ABI. #[derive(Clone, Debug)] pub struct Contract { const...
code_fim
hard
{ "lang": "rust", "repo": "eira-fransham/ethabi", "path": "/src/contract.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Iterate over all events of the contract in arbitrary order. pub fn events<'a>(&'a self) -> Box<Iterator<Item = Event> + 'a> { let iter = self.events.values().cloned(); Box::new(iter) } }<|fim_prefix|>// repo: eira-fransham/ethabi path: /src/contract.rs use std::collections...
code_fim
hard
{ "lang": "rust", "repo": "eira-fransham/ethabi", "path": "/src/contract.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ToFormatElement for JsIdentifierExpression { fn to_format_element(&self, formatter: &Formatter) -> FormatResult<FormatElement> { let JsIdentifierExpressionFields { name } = self.as_fields(); name.format(formatter) } }<|fim_prefix|>// repo: Tembocs/rome path: /crates/rome_js_...
code_fim
medium
{ "lang": "rust", "repo": "Tembocs/rome", "path": "/crates/rome_js_formatter/src/js/expressions/identifier_expression.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tembocs/rome path: /crates/rome_js_formatter/src/js/expressions/identifier_expression.rs use crate::formatter_traits::FormatTokenAndNode; use crate::{FormatElement, FormatResult, Formatter, ToFormatElement}; <|fim_suffix|>impl ToFormatElement for JsIdentifierExpression { fn to_format_eleme...
code_fim
medium
{ "lang": "rust", "repo": "Tembocs/rome", "path": "/crates/rome_js_formatter/src/js/expressions/identifier_expression.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VisionistInc/advent-of-code-2020 path: /cicavey/17/src/main.rs use aoc; use std::collections::HashMap; use std::ops::RangeInclusive; type Coord = (i64, i64, i64, i64); type Space = HashMap<Coord, State>; #[derive(Debug, Clone, Copy, PartialEq)] enum State { Inactive, Active, } impl De...
code_fim
hard
{ "lang": "rust", "repo": "VisionistInc/advent-of-code-2020", "path": "/cicavey/17/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut next_space: Space = HashMap::new(); let (xr, yr, zr, wr) = bounds(prev_space, (1,1,1,1)); for x in xr { for y in yr.clone() { for z in zr.clone() { for w in wr.clone() { let c = (x,y,z,w); let adj_count = count...
code_fim
hard
{ "lang": "rust", "repo": "VisionistInc/advent-of-code-2020", "path": "/cicavey/17/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn read_pages(&self) -> Result<BTreeMap<Map, Vec<Page>>> { let maps = proc::maps::read(&self)?; let pages = proc::pagemap::from(self.pid, &maps)?; Ok(pages) } } pub fn all() -> Result<Vec<Process>> { let mut procs = Vec::new(); for result in std::fs::read_dir("...
code_fim
hard
{ "lang": "rust", "repo": "samwho/rust-pram", "path": "/src/process.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samwho/rust-pram path: /src/process.rs use crate::proc; use lazy_static::lazy_static; use lasso::{ThreadedRodeo, Spur}; use std::{hash::Hash, sync::Arc, path::Path, fs::File, collections::BTreeMap, io::Read}; use crate::proc::maps::Map; use anyhow::Result; use crate::proc::pagemap::Page; lazy_s...
code_fim
hard
{ "lang": "rust", "repo": "samwho/rust-pram", "path": "/src/process.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.pid.partial_cmp(&other.pid) } } impl Ord for Process { fn cmp(&self, other: &Self) -> std::cmp::Ordering { self.pid.cmp(&other.pid) } } impl Hash for Process { fn hash<H: std::hash::Hasher>(&self, state: &mut H) { state.write_u64(self.pid); } } impl Proc...
code_fim
hard
{ "lang": "rust", "repo": "samwho/rust-pram", "path": "/src/process.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn deref(&self) -> &Self::Target { &self.image } } impl<I> DerefMut for Extended<I> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.image } } impl<I> AsAttachment for Extended<I> where I: AsAttachment, { type Format = I::Format; fn as_attachment(&m...
code_fim
hard
{ "lang": "rust", "repo": "RSSchermer/web_glitz.rs", "path": "/web_glitz/src/extensions/color_buffer_float.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RSSchermer/web_glitz.rs path: /web_glitz/src/extensions/color_buffer_float.rs //! Allows images that use a floating point internal format to be attached to render targets. //! //! Allows images that use the following internal formats to be attached to a //! [RenderTargetDescriptor] or [Multisamp...
code_fim
hard
{ "lang": "rust", "repo": "RSSchermer/web_glitz.rs", "path": "/web_glitz/src/extensions/color_buffer_float.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<I> AsAttachment for Extended<I> where I: AsAttachment, { type Format = I::Format; fn as_attachment(&mut self) -> Attachment<Self::Format> { self.image.as_attachment() } } impl<I> AsMultisampleAttachment for Extended<I> where I: AsMultisampleAttachment, { type SampleF...
code_fim
hard
{ "lang": "rust", "repo": "RSSchermer/web_glitz.rs", "path": "/web_glitz/src/extensions/color_buffer_float.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } } #[test] fn test_event() { assert_eq!(Event {}.meta(), CommandTypeMeta::NoQuery); } struct Default {} impl Command for Default { fn event(&self, _context: &mut Context, _args: &mut Tokenizer) -> Result<()> { Ok(()) ...
code_fim
hard
{ "lang": "rust", "repo": "occheung/scpi-rs", "path": "/scpi/src/command.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: occheung/scpi-rs path: /scpi/src/command.rs //! Command trait and helper functions. //! //! use crate::error::Result; use crate::response::ResponseUnit; use crate::tokenizer::Tokenizer; use crate::Context; /// This trait implements a command with optional event/query operations. /// /// /// # ...
code_fim
hard
{ "lang": "rust", "repo": "occheung/scpi-rs", "path": "/scpi/src/command.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) fn get_aggregations_with_accessor( aggs: &Aggregations, reader: &SegmentReader, ) -> crate::Result<AggregationsWithAccessor> { let mut metrics = vec![]; let mut buckets = vec![]; for (key, agg) in aggs.iter() { match agg { Aggregation::Bucket(bucket) => b...
code_fim
hard
{ "lang": "rust", "repo": "arastoul/tantivy", "path": "/src/aggregation/agg_req_with_accessor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arastoul/tantivy path: /src/aggregation/agg_req_with_accessor.rs //! This will enhance the request tree with access to the fastfield and metadata. use super::agg_req::{Aggregation, Aggregations, BucketAggregationType, MetricAggregation}; use super::bucket::RangeAggregation; use super::metric::{...
code_fim
hard
{ "lang": "rust", "repo": "arastoul/tantivy", "path": "/src/aggregation/agg_req_with_accessor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl BucketAggregationWithAccessor { fn from_bucket( bucket: &BucketAggregationType, sub_aggregation: &Aggregations, reader: &SegmentReader, ) -> crate::Result<BucketAggregationWithAccessor> { let (accessor, field_type) = match &bucket { BucketAggregatio...
code_fim
hard
{ "lang": "rust", "repo": "arastoul/tantivy", "path": "/src/aggregation/agg_req_with_accessor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: justthetips/grrs path: /src/main.rs use std::io::BufReader; use std::io::BufRead; use std::io::BufWriter; use std::io::Write; use structopt::StructOpt; use std::fs::File; <|fim_suffix|> for (_, line) in file.lines().enumerate(){ let l = line.unwrap(); if l.contains(&args.patt...
code_fim
hard
{ "lang": "rust", "repo": "justthetips/grrs", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("Opening {:#?}", args.path); let f = File::open(args.path).unwrap(); let file = BufReader::new(&f); let mut writer = BufWriter::new(std::io::stdout()); for (_, line) in file.lines().enumerate(){ let l = line.unwrap(); if l.contains(&args.pattern) { ...
code_fim
medium
{ "lang": "rust", "repo": "justthetips/grrs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut writer = BufWriter::new(std::io::stdout()); for (_, line) in file.lines().enumerate(){ let l = line.unwrap(); if l.contains(&args.pattern) { writeln!(writer, "{}", l).unwrap(); } } }<|fim_prefix|>// repo: justthetips/grrs path: /src/main.r...
code_fim
hard
{ "lang": "rust", "repo": "justthetips/grrs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sstanfield/hermod path: /broker/src/msglog.rs use std::collections::HashMap; use std::fs::create_dir_all; use std::fs::File; use std::fs::OpenOptions; use std::io; use std::io::{BufRead, BufReader, BufWriter, Read, Seek, SeekFrom, Write}; use std::sync::Arc; use std::time::SystemTime; use futur...
code_fim
hard
{ "lang": "rust", "repo": "sstanfield/hermod", "path": "/broker/src/msglog.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let v = format!( "{{\"Message\":{{\"topic\":\"{}\",\"payload_size\":{},\"crc\":{},\"sequence\":{}}}}}", message.tp.topic, message.payload.len(), message.crc, message.offset ); if self.single_record { // XXX need to truncate here? Pro...
code_fim
hard
{ "lang": "rust", "repo": "sstanfield/hermod", "path": "/broker/src/msglog.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn append(&mut self, messages: &mut [Message]) -> io::Result<()> { // XXX appending multiple messages vs one message seems to slow down // the 1 pub case but speed up the 100 pub case. Maybe get the IO into // another thread pool with channels for data in and out. ...
code_fim
hard
{ "lang": "rust", "repo": "sstanfield/hermod", "path": "/broker/src/msglog.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn map_buffer_readable<T: Copy>(&mut self, buf: &handle::Buffer<R, T>) -> d::mapping::Readable<T, R, Factory> { let map = self.map_buffer_raw(buf.raw(), d::MapAccess::Readable); self.map_readable(map, buf.len()) } fn map_buffer_writable<T: Copy>(&mut...
code_fim
hard
{ "lang": "rust", "repo": "fkaa/gfx_device_gl", "path": "/src/factory.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fkaa/gfx_device_gl path: /src/factory.rs // Copyright 2015 The Gfx-rs Developers. // // 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.apache.org/l...
code_fim
hard
{ "lang": "rust", "repo": "fkaa/gfx_device_gl", "path": "/src/factory.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dariost/wyvern path: /examples/add.rs extern crate wyvern; use std::sync::Arc; use wyvern::core as wcore; use wcore::builder::ProgramBuilder; use wcore::program::Program; use wcore::types::{Array, Constant, Variable}; use wyvern::core::executor::{Executable, Executor, Resource, IO}; use wyvern:...
code_fim
hard
{ "lang": "rust", "repo": "dariost/wyvern", "path": "/examples/add.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { const N: u32 = 1 << 24; let program = add(N); let executor = VkExecutor::new(Default::default()).unwrap(); let mut executable = executor.compile(program).unwrap(); let a = executor.new_resource().unwrap(); let b = executor.new_resource().unwrap(); let c = executor.n...
code_fim
medium
{ "lang": "rust", "repo": "dariost/wyvern", "path": "/examples/add.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let compacted_size_desc = optix::AccelEmitDesc::new( &compacted_size_buffer, optix::AccelPropertyType::CompactedSize, ); // allocate and execute build let temp_buffer = cuda::Buffer::new( blas_buffer_sizes[0].temp_size_in_bytes, ...
code_fim
hard
{ "lang": "rust", "repo": "oceanusxiv/optix-rs", "path": "/optix/examples/07_obj/sample_renderer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oceanusxiv/optix-rs path: /optix/examples/07_obj/sample_renderer.rs mpl<'a, AllocT> SampleRenderer<'a, AllocT> where AllocT: 'a + Allocator, { pub fn new( fb_size: V2i32, camera: Camera, model: Model, alloc: &'a AllocT, ) -> Result<SampleRenderer<'a, A...
code_fim
hard
{ "lang": "rust", "repo": "oceanusxiv/optix-rs", "path": "/optix/examples/07_obj/sample_renderer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oceanusxiv/optix-rs path: /optix/examples/07_obj/sample_renderer.rs / Check that we've got available devices let num_devices = cuda::get_device_count(); println!("Found {} CUDA devices", num_devices); // Initialize optix function table. Must be called before calling ...
code_fim
hard
{ "lang": "rust", "repo": "oceanusxiv/optix-rs", "path": "/optix/examples/07_obj/sample_renderer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn it_converts_a_turnip_pattern_with_arguments_to_a_regex_matching_description_with_single_quote_arguments() { let pattern = TurnipPattern::from(PATTERN_WITH_ARGUMENTS); let regex = pattern.to_regex(); let description = "I have a house in 'Quebec City'"; a...
code_fim
hard
{ "lang": "rust", "repo": "ianlet/encrust", "path": "/lib/src/pattern/turnip_pattern.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(regex.is_match(SIMPLE_PATTERN)); } #[test] fn it_converts_a_turnip_pattern_with_arguments_to_a_regex_matching_description_with_single_word_arguments() { let pattern = TurnipPattern::from(PATTERN_WITH_ARGUMENTS); let regex = pattern.to_regex(); let des...
code_fim
hard
{ "lang": "rust", "repo": "ianlet/encrust", "path": "/lib/src/pattern/turnip_pattern.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ianlet/encrust path: /lib/src/pattern/turnip_pattern.rs use pattern::Pattern; use regex::{Captures, Regex}; pub struct TurnipPattern { pattern: String, } impl Pattern for TurnipPattern { fn to_regex(&self) -> Regex { let re = Regex::new(r":(\w+)").unwrap(); let patter...
code_fim
hard
{ "lang": "rust", "repo": "ianlet/encrust", "path": "/lib/src/pattern/turnip_pattern.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> : : c_int = 3 ; pub const AF_LINK : : : c_int = 4 ; pub const AF_INET6 : : : c_int = 5 ; pub const AF_DLI : : : c_int = 6 ; pub const AF_IPX : : : c_int = 7 ; pub const AF_NOTIFY : : : c_int = 8 ; pub const AF_LOCAL : : : c_int = 9 ; pub const AF_UNIX : : : c_int = AF_LOCAL ; pub const AF_BLUETOOTH : : :...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/libc/src/unix/haiku/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/libc/src/unix/haiku/mod.rs ag_t = 0x00000100 ; pub const IEXTEN : : : tcflag_t = 0x00000200 ; pub const ECHOCTL : : : tcflag_t = 0x00000400 ; pub const ECHOPRT : : : tcflag_t = 0x00000800 ; pub const ECHOKE : : : tcflag_t = 0x00001000 ; pub con...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/libc/src/unix/haiku/mod.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>_int = 0 ; pub const SEEK_CUR : : : c_int = 1 ; pub const SEEK_END : : : c_int = 2 ; pub const _IOFBF : : : c_int = 0 ; pub const _IONBF : : : c_int = 2 ; pub const _IOLBF : : : c_int = 1 ; pub const F_DUPFD : : : c_int = 0x0001 ; pub const F_GETFD : : : c_int = 0x0002 ; pub const F_SETFD : : : c_int = 0x...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/libc/src/unix/haiku/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Happy-Ferret/r68k path: /tools/src/assembler/mod.rs use operand::Operand; use memory::{Memory, MemoryVec}; use super::{OpcodeInstance, Size}; pub mod parser; fn encode_ea(op: &Operand) -> u16 { (match *op { Operand::DataRegisterDirect(reg_y) => 0b000000 | reg_y, Operand::Add...
code_fim
hard
{ "lang": "rust", "repo": "Happy-Ferret/r68k", "path": "/tools/src/assembler/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn encode_imm_ea(op: &OpcodeInstance, template: u16, pc: u32, mem: &mut Memory) -> u32 { let ea = encode_ea(&op.operands[1]); assert_no_overlap(&op, template, ea, 0); let pc = mem.write_word(pc, template | ea); let pc = op.operands[0].add_extension_words(pc, mem); op.operands[1].ad...
code_fim
hard
{ "lang": "rust", "repo": "Happy-Ferret/r68k", "path": "/tools/src/assembler/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let args: Vec<String> = env::args().collect(); let path = &args[1]; let input = read_file(path) .expect("Error reading file."); let input = split_string(&input); let slopes: Vec<(usize, usize)> = vec![ (1, 1), (3, 1), (5, 1), (7, 1), (1...
code_fim
hard
{ "lang": "rust", "repo": "goibon/advent-of-code-2020", "path": "/day_3/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: goibon/advent-of-code-2020 path: /day_3/src/main.rs use std::env; use std::fs::File; use std::io::Read; const START_X: usize = 0; const START_Y: usize = 0; const TREE_CHARACTER: char = '#'; fn read_file(file_path: &str) -> std::io::Result<String> { let mut file = File::open(file_path)?; ...
code_fim
hard
{ "lang": "rust", "repo": "goibon/advent-of-code-2020", "path": "/day_3/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut count: u8 = 0; let mut move_result = move_tobaggo(START_X, START_Y, move_x, move_y, map); while let Some((new_x, new_y, tree_hit)) = move_result { if tree_hit { count += 1; } if new_y + move_y >= map.len() { break } move_...
code_fim
hard
{ "lang": "rust", "repo": "goibon/advent-of-code-2020", "path": "/day_3/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Arpanbhagat5/resto-api path: /src/orders.rs use diesel; use diesel::dsl::*; use diesel::prelude::*; use diesel::pg::PgConnection; use diesel::sql_query; use diesel::sql_types::*; use super::schema::tables; use super::schema::status; use super::schema::menu; use super::schema::orders; use super...
code_fim
hard
{ "lang": "rust", "repo": "Arpanbhagat5/resto-api", "path": "/src/orders.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // if count of not "served" return false if unserved_items > 0 { return false } else { return true } } pub fn get_order_list_for_table(table_id: i32, conn: &PgConnection) { let order_num = Orders::get_order_id_from_table_id(table_id, &conn); let result: Vec<Or...
code_fim
hard
{ "lang": "rust", "repo": "Arpanbhagat5/resto-api", "path": "/src/orders.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let chain_height = match client.request("Synchronize", &serde_json::to_vec(&SyncType::GetHeight).map_err(|e|QanError::Serde(e))?, std::time::Duration::new(8,0)){ Ok(h)=>String::from_utf8_lossy(&h.payload).to_string().parse::<u64>().unwrap(), Err(_) => 0 }; info!("I have {} bloc...
code_fim
hard
{ "lang": "rust", "repo": "webclinic017/its_alive", "path": "/src/sync.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: webclinic017/its_alive path: /src/sync.rs use crate::user_client::{start_client, start_stdin_handler}; use crate::transaction::{Transaction, TxBody}; use natsclient::{self, ClientOptions, Client}; use std::{ time::Duration, sync::{Arc, RwLock}, path::Path, fs::File, io::Read,...
code_fim
hard
{ "lang": "rust", "repo": "webclinic017/its_alive", "path": "/src/sync.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sebastianpiskorski/memory_usage path: /src/main.rs extern crate jemallocator; extern crate jemalloc_ctl; use jemalloc_ctl::{stats, epoch}; use rand::distributions::Alphanumeric; use rand::{thread_rng, Rng}; use std::collections::VecDeque; use std::mem; #[global_allocator] static ALLOC: jemallo...
code_fim
hard
{ "lang": "rust", "repo": "sebastianpiskorski/memory_usage", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn rand_string(length: usize) -> String { thread_rng() .sample_iter(&Alphanumeric) .take(length) .map(char::from) .collect::<String>() } fn print_mem_usage( message: String ) { epoch::advance().unwrap(); let allocated = stats::allocated::read().unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "sebastianpiskorski/memory_usage", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if !config.emit_bc { debug!("removing_bitcode {:?}", bc_out); if let Err(e) = fs::remove_file(&bc_out) { diag_handler.err(&format!("failed to remove bitcode: {}", e)); } }*/ } ...
code_fim
hard
{ "lang": "rust", "repo": "dkm/rustc_codegen_gcc", "path": "/src/back/write.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dkm/rustc_codegen_gcc path: /src/back/write.rs use std::fs; use gccjit::OutputKind; use rustc_codegen_ssa::{CompiledModule, ModuleCodegen}; use rustc_codegen_ssa::back::write::{CodegenContext, EmitObj, ModuleConfig}; use rustc_errors::Handler; use rustc_session::config::OutputType; use rustc_sp...
code_fim
hard
{ "lang": "rust", "repo": "dkm/rustc_codegen_gcc", "path": "/src/back/write.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> //drop(handlers); } Ok(module.into_compiled_module( config.emit_obj != EmitObj::None, cgcx.target_can_use_split_dwarf && cgcx.split_debuginfo == SplitDebuginfo::Unpacked, config.emit_bc, &cgcx.output_filenames, )) } pub(crate) fn link(_cgcx: &CodegenCo...
code_fim
hard
{ "lang": "rust", "repo": "dkm/rustc_codegen_gcc", "path": "/src/back/write.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Default for EmitterConfig { #[inline] fn default() -> EmitterConfig { EmitterConfig::new() } } gen_setters!(EmitterConfig, line_separator: into Cow<'static, str>, indent_string: into Cow<'static, str>, perform_indent: val bool, write_document_declaration: val bool...
code_fim
hard
{ "lang": "rust", "repo": "mitsuhiko/elementtree-rust", "path": "/src/xml/writer/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mitsuhiko/elementtree-rust path: /src/xml/writer/config.rs //! Contains emitter configuration structure. use std::borrow::Cow; use std::io::Write; use crate::xml::writer::EventWriter; /// Emitter configuration structure. /// /// This structure contains various options which control XML docume...
code_fim
hard
{ "lang": "rust", "repo": "mitsuhiko/elementtree-rust", "path": "/src/xml/writer/config.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/libc/v0_2/crate/src/unix/solarish/illumos.rs s! { pub struct shmid_ds { pub shm_perm: ::ipc_perm, pub shm_segsz: ::size_t, pub shm_amp: *mut ::c_void, pub shm_lkcnt: ::c_ushort, pub shm_lpid: ::pid_t, p...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/libc/v0_2/crate/src/unix/solarish/illumos.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn mincore(addr: ::caddr_t, len: ::size_t, vec: *mut ::c_char) -> ::c_int; pub fn pset_bind_lwp( pset: ::psetid_t, id: ::id_t, pid: ::pid_t, opset: *mut ::psetid_t, ) -> ::c_int; pub fn pset_getloadavg(pset: ::psetid_t, load: *mut ::c_double, num: ::c_i...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/libc/v0_2/crate/src/unix/solarish/illumos.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// sys/systeminfo.h pub const SI_ADDRESS_WIDTH: ::c_int = 520; extern "C" { pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; pub fn mincore(addr: ::caddr_t, len: ::size_t, vec: *mut ::c_char) -> ::c_int; pub fn pset_bind_lwp( pset: ::psetid_t, id: ::id_t, p...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/libc/v0_2/crate/src/unix/solarish/illumos.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bertiespell/cryptopals path: /set1/decrypt_repeating/src/main.rs extern crate decrypt_repeating; use std::fs; pub mod base_64; use decrypt_repeating::decrypt_repeating_xor; <|fim_suffix|> let text = fs::read_to_string("text.txt").expect("Unable to read file"); let text_bytes = base_64::d...
code_fim
easy
{ "lang": "rust", "repo": "bertiespell/cryptopals", "path": "/set1/decrypt_repeating/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let text = fs::read_to_string("text.txt").expect("Unable to read file"); let text_bytes = base_64::decode(text.as_bytes()); let decypted = decrypt_repeating_xor(text_bytes); println!("Decrypted: {:?}", decypted); }<|fim_prefix|>// repo: bertiespell/cryptopals path: /set1/decrypt_repeating...
code_fim
easy
{ "lang": "rust", "repo": "bertiespell/cryptopals", "path": "/set1/decrypt_repeating/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:?}", outer); let iBags = match parts[1] { "no other bags" => Vec::new(), _ => { let innerPieces = parts[1].split(" ").collect::<Vec<&str>>(); let mut innerBags: Vec<BagDescription> = Vec::new(); l...
code_fim
hard
{ "lang": "rust", "repo": "itsananderson/advent-of-code-2020", "path": "/rust/src/bin/07-solution2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: itsananderson/advent-of-code-2020 path: /rust/src/bin/07-solution2.rs use std::env; use std::fs; use std::string::String; use regex::Regex; use std::collections::HashSet; use std::collections::HashMap; #[derive(Debug)] #[derive(Clone)] struct BagDescription { count: usize, ...
code_fim
hard
{ "lang": "rust", "repo": "itsananderson/advent-of-code-2020", "path": "/rust/src/bin/07-solution2.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut runningCount: usize = 1; match bagChildren.get(&bagDescription) { Some(children) => { for child in children { runningCount += child.count * bagCount(&bagChildren, child.description.clone()); } }, None => {} } ...
code_fim
hard
{ "lang": "rust", "repo": "itsananderson/advent-of-code-2020", "path": "/rust/src/bin/07-solution2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bjrnmrtns/xp-game-engine path: /low_poly_nice_graphics/src/renderer/vertex_buffer.rs use crate::{ mesh::{Mesh, Vertex}, renderer::Renderer, }; use wgpu::util::DeviceExt; #[repr(C)] #[derive(Debug)] pub struct VertexBuffer { pub vertex_buffer: wgpu::Buffer, pub index_buffer: wgpu...
code_fim
hard
{ "lang": "rust", "repo": "bjrnmrtns/xp-game-engine", "path": "/low_poly_nice_graphics/src/renderer/vertex_buffer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Vertex { pub fn desc<'a>() -> wgpu::VertexBufferLayout<'a> { use std::mem; wgpu::VertexBufferLayout { array_stride: mem::size_of::<Self>() as wgpu::BufferAddress, step_mode: wgpu::InputStepMode::Vertex, attributes: &[ wgpu::Verte...
code_fim
hard
{ "lang": "rust", "repo": "bjrnmrtns/xp-game-engine", "path": "/low_poly_nice_graphics/src/renderer/vertex_buffer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //Parse the lines and populate the map let mut map = HashMap::new(); for line in contents.lines() { //split the each line into two tokens by ':' //And first token will be key and second token will be value let mut tokens = line.splitn(2,':'); ...
code_fim
hard
{ "lang": "rust", "repo": "srinivas-chundi/cargo", "path": "/kvstore/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: srinivas-chundi/cargo path: /kvstore/src/main.rs //use std::env::Args; use std::collections::HashMap; fn main() { let mut args = std::env::args().skip(1); let key = args.next().expect("Key is missing"); let db = Database::new().expect("Failed to load kv.db"); let value = db.map....
code_fim
medium
{ "lang": "rust", "repo": "srinivas-chundi/cargo", "path": "/kvstore/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/instr_pcmpeqb.rs use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_pcmpeqb.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::PCMPEQB, operand1: Some(Direct(MM7)), operand2: Some(IndirectScaledIndexedDisplaced(RDI, RSI, Four, 1530167701, Some(OperandSize::Qword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broa...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_pcmpeqb.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joshradin/apfmalloc path: /src/page_map.rs use crate::allocation_data::Descriptor; use crate::mem_info::{LG_PAGE, MAX_SZ, MAX_SZ_IDX}; #[cfg(not(unix))] use crate::mem_info::PAGE; use bitfield::size_of; use std::ptr::slice_from_raw_parts_mut; use crate::pages::page_alloc_over_commit; use crate...
code_fim
hard
{ "lang": "rust", "repo": "joshradin/apfmalloc", "path": "/src/page_map.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_ptr(&mut self, desc: *mut Descriptor, sc_idx: usize) { let ptr = desc; if ptr as usize & SC_MASK as usize != 0 || sc_idx >= MAX_SZ_IDX { self.desc = null_mut(); return; } let desc = (ptr as usize | sc_idx) as *mut Descriptor; ...
code_fim
hard
{ "lang": "rust", "repo": "joshradin/apfmalloc", "path": "/src/page_map.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> */ let key = ((ptr as *const u8 as usize) >> PM_KEY_SHIFT) & PM_KEY_MASK as usize; key } #[cfg(windows)] unsafe fn get_page(&self, start_location: *mut u8, key: usize) -> LPVOID { /* let offset: isize = (key * size_of::<Atomic<PageInfo>>()) as isize; ...
code_fim
hard
{ "lang": "rust", "repo": "joshradin/apfmalloc", "path": "/src/page_map.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>{ let x = 3.0; let y = 2.0; let result:Option<f64> = if y != 0.0 { Some(x/y) } else { None }; println!("{:?}", result); // ok. //println!("{}", result); // error! } fn main() { options(); unions(); }<|fim_prefix|>// repo: vztpv/Rust-Pratice path: /pratice/a.rs uni...
code_fim
medium
{ "lang": "rust", "repo": "vztpv/Rust-Pratice", "path": "/pratice/a.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:?}", result); // ok. //println!("{}", result); // error! } fn main() { options(); unions(); }<|fim_prefix|>// repo: vztpv/Rust-Pratice path: /pratice/a.rs union IntOrFloat { i: i32, f: f32 } fn process_value(iof: IntOrFloat) { unsafe { match iof { ...
code_fim
medium
{ "lang": "rust", "repo": "vztpv/Rust-Pratice", "path": "/pratice/a.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vztpv/Rust-Pratice path: /pratice/a.rs union IntOrFloat { i: i32, f: f32 } fn process_value(iof: IntOrFloat) { unsafe { match iof { IntOrFloat { i : 24 } => { println!("int is {}", iof.i); } IntOrFloat { f } => { println!("f32 = {}", f); } ...
code_fim
medium
{ "lang": "rust", "repo": "vztpv/Rust-Pratice", "path": "/pratice/a.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tembocs/rome path: /crates/rome_analyze/src/analyzers.rs pub(crate) mod no_double_equals; pub(crate) mod no_var; pub(crate) mod use_single_case_statement; pub(crate) mod use_while; use rome_diagnostics::{Diagnostic, Span}; use rome_js_syntax::{JsLanguage, JsSyntaxNode, TextRange}; use rome_rowa...
code_fim
hard
{ "lang": "rust", "repo": "Tembocs/rome", "path": "/crates/rome_analyze/src/analyzers.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> AnalyzerContext<'a> { pub(crate) fn new( analysis_server: &'a AnalysisServer, file_id: FileId, analyzer: &'a Analyzer, ) -> Self { Self { analysis_server, file_id, analyzer, } } /// Get the root [SyntaxNo...
code_fim
hard
{ "lang": "rust", "repo": "Tembocs/rome", "path": "/crates/rome_analyze/src/analyzers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/parser/public-instead-of-pub-1.rs // Checks what happens when `public` is used instead of the correct, `pub` // run-rustfix <|fim_suffix|> //~^ ERROR expected one of `!` or `::`, found keyword `enum` //~^^ HELP write `pub` instead of `public` to make the it...
code_fim
easy
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/parser/public-instead-of-pub-1.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> //~^ ERROR expected one of `!` or `::`, found keyword `enum` //~^^ HELP write `pub` instead of `public` to make the item public A, B, } fn main() { }<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/parser/public-instead-of-pub-1.rs // Checks what happens when `public` is used instea...
code_fim
easy
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/parser/public-instead-of-pub-1.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: winter-yuki/rust-rt path: /image/src/lib.rs extern crate color; extern crate png; use std::{fs, io}; use std::num::NonZeroUsize; use std::ops::{Index, IndexMut}; use std::path::Path; pub type Color = color::Color<u8>; pub enum Error { WriteIO(io::Error) } impl From<io::Error> for Error {...
code_fim
hard
{ "lang": "rust", "repo": "winter-yuki/rust-rt", "path": "/image/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let img = Image(data); assert!(img.h() > 0); assert!(img.w() > 0); img } } impl Index<(usize, usize)> for Image { type Output = Color; fn index(&self, (i_row, i_col): (usize, usize)) -> &Self::Output { &self.0[i_row][i_col] } } impl IndexMut<(usiz...
code_fim
hard
{ "lang": "rust", "repo": "winter-yuki/rust-rt", "path": "/image/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone, Debug)] pub struct Image(Vec<Vec<Color>>); impl Image { pub fn from_size(w: NonZeroUsize, h: NonZeroUsize) -> Self { Image(vec![ vec![Color::black(); usize::from(w)]; usize::from(h) ]) } pub fn write_png(&self, path: &Path) -> Result<()...
code_fim
hard
{ "lang": "rust", "repo": "winter-yuki/rust-rt", "path": "/image/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MrRobb/tetris-rs path: /src/tetris/model/board.rs use super::shape::{self, Shape}; use na::{zero, MatrixMN, Vec2, U12, U22}; use rand::prelude::*; use rand::Rng; // Struct: Piece #[derive(Clone, Copy)] pub struct Piece { pub position: Vec2<usize>, pub shape: Shape, } impl Piece { pub fn ne...
code_fim
hard
{ "lang": "rust", "repo": "MrRobb/tetris-rs", "path": "/src/tetris/model/board.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn can_left(board: &Board, piece: &Piece) -> bool { !overlapping(board, piece, -1, 0) } fn can_right(board: &Board, piece: &Piece) -> bool { !overlapping(board, piece, 1, 0) } fn can_rotate(board: &Board, piece: &Piece) -> Result<Piece, BoardError> { let mut new_piece = piece.clone().shape(piece.shap...
code_fim
hard
{ "lang": "rust", "repo": "MrRobb/tetris-rs", "path": "/src/tetris/model/board.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Set current piece let current_piece = Piece { position: [4, 2].into(), shape: collector.get_current(), }; // Build state Self { grid, collector, current: current_piece, } } /// Transfer current piece to grid pub fn place_current_piece(&mut self) { let offset_y: usize =...
code_fim
hard
{ "lang": "rust", "repo": "MrRobb/tetris-rs", "path": "/src/tetris/model/board.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Generator { pub fn preview_features(&self) -> BitFlags<PreviewFeature> { self.preview_features.iter().copied().collect() } }<|fim_prefix|>// repo: debragail/prisma-engines path: /libs/datamodel/core/src/configuration/generator.rs use crate::{common::preview_features::PreviewFeature, ...
code_fim
hard
{ "lang": "rust", "repo": "debragail/prisma-engines", "path": "/libs/datamodel/core/src/configuration/generator.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[serde(default)] pub preview_features: Vec<PreviewFeature>, #[serde(skip_serializing_if = "Option::is_none")] pub documentation: Option<String>, } impl Generator { pub fn preview_features(&self) -> BitFlags<PreviewFeature> { self.preview_features.iter().copied().collect() ...
code_fim
medium
{ "lang": "rust", "repo": "debragail/prisma-engines", "path": "/libs/datamodel/core/src/configuration/generator.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: debragail/prisma-engines path: /libs/datamodel/core/src/configuration/generator.rs use crate::{common::preview_features::PreviewFeature, configuration::StringFromEnvVar}; use enumflags2::BitFlags; use serde::Serialize; use std::collections::HashMap; <|fim_suffix|> #[serde(default)] pub b...
code_fim
hard
{ "lang": "rust", "repo": "debragail/prisma-engines", "path": "/libs/datamodel/core/src/configuration/generator.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 3Hren/photon path: /src/vec3.rs use std::ops::{Add, Mul, Sub}; #[derive(Copy, Clone, Debug, Default, Deserialize, PartialEq, Serialize)] pub struct Vec3<T> { pub x: T, pub y: T, pub z: T, } impl<T> Vec3<T> { #[inline] pub fn new(x: T, y: T, z: T) -> Self { Self { x,...
code_fim
hard
{ "lang": "rust", "repo": "3Hren/photon", "path": "/src/vec3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub fn unit(&self) -> Vec3<f64> { let len = self.len(); Vec3 { x: self.x / len, y: self.y / len, z: self.z / len, } } #[inline] pub fn inverse(&self) -> Vec3<f64> { Vec3 { x: -self.x, ...
code_fim
hard
{ "lang": "rust", "repo": "3Hren/photon", "path": "/src/vec3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: Sub<Output = T>> Sub for Vec3<T> { type Output = Vec3<T>; #[inline] fn sub(self, other: Vec3<T>) -> Self::Output { Vec3 { x: self.x - other.x, y: self.y - other.y, z: self.z - other.z, } } }<|fim_prefix|>// repo: 3Hren/photon pa...
code_fim
hard
{ "lang": "rust", "repo": "3Hren/photon", "path": "/src/vec3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }