text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: sindrehan/mkl82z7-pac path: /src/cmp0/cr1.rs core::ops::DerefMut for W { #[inline(always)] fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } impl From<crate::W<CR1_SPEC>> for W { #[inline(always)] fn from(writer: crate::W<CR1_SPEC>) -> Self { W(wr...
code_fim
hard
{ "lang": "rust", "repo": "sindrehan/mkl82z7-pac", "path": "/src/cmp0/cr1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sindrehan/mkl82z7-pac path: /src/cmp0/cr1.rs , this field has no effect."] #[inline(always)] pub fn _0(self) -> &'a mut W { self.variant(OPE_A::_0) } #[doc = "CMPO is available on the associated CMPO output pin. The comparator output (CMPO) is driven out on the associated...
code_fim
hard
{ "lang": "rust", "repo": "sindrehan/mkl82z7-pac", "path": "/src/cmp0/cr1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> variant as u8 != 0 } } #[doc = "Field `WE` reader - Windowing Enable"] pub struct WE_R(crate::FieldReader<bool, WE_A>); impl WE_R { pub(crate) fn new(bits: bool) -> Self { WE_R(crate::FieldReader::new(bits)) } #[doc = r"Get enumerated values variant"] #[inline(always)] ...
code_fim
hard
{ "lang": "rust", "repo": "sindrehan/mkl82z7-pac", "path": "/src/cmp0/cr1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dgurnani12/SEGIMAP path: /mime/src/lib.rs use std::ascii::AsciiExt; use std::collections::HashMap; use std::fs::File; use std::io::Read; use std::path::Path; use std::str; pub use self::command::BodySectionType; use self::command::BodySectionType::{ AllSection, MsgtextSection, PartS...
code_fim
hard
{ "lang": "rust", "repo": "dgurnani12/SEGIMAP", "path": "/mime/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Remove the "Received" key from the HashMap. let received_key = &RECEIVED.to_string(); if headers.get(received_key).is_some() { headers.remove(received_key); } // Determine whether the message is MULTIPART or not. let mut body = Vec::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "dgurnani12/SEGIMAP", "path": "/mime/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nukep/rust-cubes-demo path: /src/game/cube.rs use std; use rand; use rand::StdRng; use cgmath; use cgmath::{Vector, Vector3, Quaternion, Rotation, Ray3, Zero}; struct CubeStateRearranging { p: f32, next_state: Box<CubeState> } enum CubeState { Simulating, Resetting, Rearran...
code_fim
hard
{ "lang": "rust", "repo": "nukep/rust-cubes-demo", "path": "/src/game/cube.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Transform subcube from a no-rotation, unit cube with its origin at the lower-front-left corner let segment_model = Matrix4::identity() .translate_v(&self.segment) .scale_s(self.subcube_length) .translate_s(-0.5); let model = self.get_model_ma...
code_fim
hard
{ "lang": "rust", "repo": "nukep/rust-cubes-demo", "path": "/src/game/cube.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn rand<RNG: rand::Rng>(rng: &mut RNG) -> f32 { rng.next_f32() * 2.0 - 1.0 } Vector3::new(rand(rng), rand(rng), rand(rng)) } let v = self.pos.sub_v(origin).mul_s(16.0); self.vel = (v + random_vector3(rng).mul_s(4.0)).mul_s(force*...
code_fim
hard
{ "lang": "rust", "repo": "nukep/rust-cubes-demo", "path": "/src/game/cube.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bidhan-a/dream path: /src/sources/stdin.rs use crate::sources::{Message, Result, Sender, Source}; use std::io::{self, BufReader, Read}; const CHUNK_SIZE: usize = 16 * 1024; // 16 kb. #[derive(Clone)] pub struct StdinSource {} impl Source for StdinSource { type T = Vec<u8>; fn name(&se...
code_fim
medium
{ "lang": "rust", "repo": "bidhan-a/dream", "path": "/src/sources/stdin.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> "Stdin Source".to_owned() } fn start(self, tx: Sender<Message<Self::T>>) -> Result<()> { let mut reader: Box<dyn Read> = Box::new(BufReader::new(io::stdin())); let mut buffer = [0; CHUNK_SIZE]; loop { let num_read = match reader.read(&mut buffer) { ...
code_fim
medium
{ "lang": "rust", "repo": "bidhan-a/dream", "path": "/src/sources/stdin.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut mgr = KcpSessionManager::new(&handle).unwrap(); let updater = mgr.clone(); let svr = listener.incoming().for_each(|(client, addr)| { debug!("Accepted TCP connection {}, relay to {}", addr, &config.remote_addr); let chandle = handle.clone(); let mut updater = upd...
code_fim
hard
{ "lang": "rust", "repo": "u20024804/sskcp-proxy", "path": "/src/local.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: u20024804/sskcp-proxy path: /src/local.rs use std::io; use futures::{self, Future, Stream}; use futures::future::Either; use tokio_core::net::TcpListener; use tokio_core::reactor::Core; use tokio_io::AsyncRead; use tokio_io::io::{write_all, read_exact, flush}; use tokio_kcp::{KcpStream, KcpSess...
code_fim
hard
{ "lang": "rust", "repo": "u20024804/sskcp-proxy", "path": "/src/local.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: quilt/dahe path: /src/list.rs use crate::config::Config; use anyhow::Result; use structopt::StructOpt; <|fim_suffix|>pub fn list() -> Result<()> { let config = Config::open()?; config.print(); Ok(()) }<|fim_middle|>#[derive(Debug, StructOpt)] pub struct List {}
code_fim
easy
{ "lang": "rust", "repo": "quilt/dahe", "path": "/src/list.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn list() -> Result<()> { let config = Config::open()?; config.print(); Ok(()) }<|fim_prefix|>// repo: quilt/dahe path: /src/list.rs use crate::config::Config; use anyhow::Result; use structopt::StructOpt; <|fim_middle|>#[derive(Debug, StructOpt)] pub struct List {}
code_fim
easy
{ "lang": "rust", "repo": "quilt/dahe", "path": "/src/list.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; use crate::events::types::*; use fidl_fuchsia_logger::LogSinkMarker; use fuchsia_async as fasync; use futures::StreamExt; use std::collections::BTreeSet; #[fuchsia::test] async fn events_have_unknown_identity() { let events = ...
code_fim
medium
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/diagnostics/archivist/src/events/sources/unattributed_log_sink.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/diagnostics/archivist/src/events/sources/unattributed_log_sink.rs // Copyright 2021 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use crate::{ events::{ ro...
code_fim
medium
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/diagnostics/archivist/src/events/sources/unattributed_log_sink.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tflovorn/w90-rs path: /src/qe_workflow.rs use qe::pw::input::Input as PwInput; use qe::pw::input::{Calculation, Ibrav, KPoints, Occupations, Smearing, SpinType}; use qe::pw::input::LatticeUnits as PwLatticeUnits; use qe::pw::input::PositionCoordinateType as PwCoord; use qe::pw::input::AtomCoordi...
code_fim
hard
{ "lang": "rust", "repo": "tflovorn/w90-rs", "path": "/src/qe_workflow.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn w90_input( nscf: &PwInput, num_wann: u64, mlwf_iteration_mode: &MLWFIterationMode, disentanglement: &Disentanglement, projection_units: Option<W90LatticeUnits>, projections: Vec<Projection>, ) -> Result<W90Input, Error> { let num_bands = match nscf.calculation { ...
code_fim
hard
{ "lang": "rust", "repo": "tflovorn/w90-rs", "path": "/src/qe_workflow.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: richwandell/rtop path: /src/utils/mod.rs pub fn left_pad(text: String, len: usize) -> String { let mut pad_text = String::new(); for _ in 0..(len - text.len()) { pad_text += " "; } return pad_text.to_string() + &text; } pub fn right_pad(text: String, len: usize) -> Strin...
code_fim
medium
{ "lang": "rust", "repo": "richwandell/rtop", "path": "/src/utils/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return pad.clone() + &text + &pad; } pub fn make_bars(perc: f64) -> String { let num_bars = (perc * 25.0) as i64; let mut bars = "".to_string(); for _ in 0..num_bars { bars += "|"; } if bars.len() < 25 { for _ in 0..25-bars.len() { bars += " "; ...
code_fim
medium
{ "lang": "rust", "repo": "richwandell/rtop", "path": "/src/utils/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<P, M> HasBoundingVolume<M, AABB<P>> for Triangle<P> where P: Point, M: Transform<P> + Rotate<P::Vect> { #[inline] fn bounding_volume(&self, m: &M) -> AABB<P> { // FIXME: optimize that bounding_volume::implicit_shape_aabb(m, self) } } impl<P, M> HasBoundingVo...
code_fim
hard
{ "lang": "rust", "repo": "futile/ncollide", "path": "/ncollide_entities/bounding_volume/aabb_support_map.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: futile/ncollide path: /ncollide_entities/bounding_volume/aabb_support_map.rs use na::{Rotate, Transform}; use bounding_volume::{HasBoundingVolume, AABB}; use bounding_volume; use shape::{Cone, Cylinder, Capsule}; use shape::{Triangle, Segment}; use math::{Point, Vect}; impl<P, M> HasBoundingVol...
code_fim
hard
{ "lang": "rust", "repo": "futile/ncollide", "path": "/ncollide_entities/bounding_volume/aabb_support_map.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl HitRecord { pub fn new() -> Self { HitRecord { t: 0.0, contact: Vector3f::new(0.0, 0.0, 0.0), normal: Vector3f::new(0.0, 0.0, 0.0), material: Rc::new(EmptyMaterial{}), } } }<|fim_prefix|>// repo: aaneto/vault path: /rrweekend/sr...
code_fim
medium
{ "lang": "rust", "repo": "aaneto/vault", "path": "/rrweekend/src/hitrecord.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aaneto/vault path: /rrweekend/src/hitrecord.rs use std::rc::Rc; use crate::prelude::{ Material, EmptyMaterial, Vector3f, }; <|fim_suffix|>impl HitRecord { pub fn new() -> Self { HitRecord { t: 0.0, contact: Vector3f::new(0.0, 0.0, 0.0), ...
code_fim
medium
{ "lang": "rust", "repo": "aaneto/vault", "path": "/rrweekend/src/hitrecord.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NirvanaNimbusa/revault_tx path: /src/scripts.rs escriptor::DescriptorPublicKey, policy::concrete::Policy, Descriptor, MiniscriptKey, Segwitv0, }; use std::fmt; // These are useful to create TxOuts out of the right Script descriptor macro_rules! impl_descriptor_newtype { ($struct_n...
code_fim
hard
{ "lang": "rust", "repo": "NirvanaNimbusa/revault_tx", "path": "/src/scripts.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NirvanaNimbusa/revault_tx path: /src/scripts.rs blicKey> { /// Derives all wildcard keys in the descriptor using the supplied `child_number` pub fn derive( &self, child_number: bip32::ChildNumber, ) -> $struct_name<DescriptorPub...
code_fim
hard
{ "lang": "rust", "repo": "NirvanaNimbusa/revault_tx", "path": "/src/scripts.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let cosigners_and_csv = Policy::And(vec![cosigners_thres, Policy::Older(csv_value)]); let managers_and_cosigners_and_csv = Policy::And(vec![spenders_thres, cosigners_and_csv]); let policy = Policy::Or(vec![ (1, stakeholders_thres), (9, managers_and_cosigners_and_csv), ]);...
code_fim
hard
{ "lang": "rust", "repo": "NirvanaNimbusa/revault_tx", "path": "/src/scripts.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> .set_width(Pixels(100.0)) .set_height(Pixels(30.0)) .set_background_color(Color::from("#ff5e1a")) .set_child_space(Stretch(1.0)) }); }); app.run(); }<|fim_prefix|>// repo: lineCode/tuix path: /examples/h...
code_fim
hard
{ "lang": "rust", "repo": "lineCode/tuix", "path": "/examples/hello_gui.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lineCode/tuix path: /examples/hello_gui.rs use tuix::*; fn main() { let app = Application::new(WindowDescription::new().with_title("Hello GUI"), |state, window| { Button::with_label("Button") .build(state, window.entity(), |builder| { builder<|f...
code_fim
hard
{ "lang": "rust", "repo": "lineCode/tuix", "path": "/examples/hello_gui.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nushell/nushell path: /crates/nu-command/src/strings/encode_decode/encode_base64.rs use super::base64::{operate, ActionType, CHARACTER_SET_DESC}; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ Category, Example, PipelineData, ShellError...
code_fim
hard
{ "lang": "rust", "repo": "nushell/nushell", "path": "/crates/nu-command/src/strings/encode_decode/encode_base64.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> vec![ Example { description: "Encode binary data", example: "0x[09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0] | encode base64", result: Some(Value::test_string("CfkRAp1041vYQVbFY1aIwA==")), }, Example { ...
code_fim
hard
{ "lang": "rust", "repo": "nushell/nushell", "path": "/crates/nu-command/src/strings/encode_decode/encode_base64.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gereeter/llvm-safe path: /src/llvm/mod.rs pub use self::context::Context; pub use self::module::{Module, ModuleBuilder}; pub use self::function::{Function, FunctionLabel, FunctionBuilder}; pub use self::builder::{Builder, PositionedBuilder}; pub use self::block::{BasicBlock, Label}; pub use self...
code_fim
hard
{ "lang": "rust", "repo": "gereeter/llvm-safe", "path": "/src/llvm/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// // TODO: Error Checking // This is currently a safety hole. // // TODO: Reduce the number of lifetimes. // It isn't completely clear that this is possible, but this is a first attempt. // // TODO: Docs // // TODO: See what safety guarentees LLVM actually needs. // The official LLVM docs aren't ve...
code_fim
hard
{ "lang": "rust", "repo": "gereeter/llvm-safe", "path": "/src/llvm/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn consume(&mut self, kind: TokenKind, msg: &str) { if self.eat(kind) { return; } quit!(&self.src, self.curr.span, msg); } fn eat(&mut self, kind: TokenKind) -> bool { if self.curr.kind == kind { self.advance(); true ...
code_fim
hard
{ "lang": "rust", "repo": "95th/arith", "path": "/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 95th/arith path: /src/parser.rs use crate::{ lexer::{Lexer, Symbol, Token, TokenKind, TokenKind::*}, span::Span, syntax::{Term, TermKind, TyContext}, }; use std::rc::Rc; pub struct Parser { lexer: Lexer, curr: Token, prev: Token, src: Rc<String>, } impl Parser { ...
code_fim
hard
{ "lang": "rust", "repo": "95th/arith", "path": "/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joelarmstrong/aoc18 path: /src/aoc4.rs use std::io; use std::io::BufRead; use std::collections::BTreeMap; use failure::{Error, format_err, bail}; use regex::Regex; use std::ops::Range; pub fn aoc4(part2: bool) -> Result<(), Error> { let stdin = io::stdin(); let sorted_string = sort_time...
code_fim
hard
{ "lang": "rust", "repo": "joelarmstrong/aoc18", "path": "/src/aoc4.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_result_ok(parse_shifts(TIME_STRING.as_bytes()), vec![ GuardShift { id: 10, sleeps: vec![(5..25), (30..55)], }, GuardShift { id: 99, sleeps: vec![(40..50)], }, GuardShi...
code_fim
hard
{ "lang": "rust", "repo": "joelarmstrong/aoc18", "path": "/src/aoc4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cobalt-org/liquid-rust path: /tests/conformance_ruby/tags/standard_tag_test.rs #[test] fn test_no_transform() { assert_template_result!( "this text should come out of the template without change...", "this text should come out of the template without change..." ); as...
code_fim
hard
{ "lang": "rust", "repo": "cobalt-org/liquid-rust", "path": "/tests/conformance_ruby/tags/standard_tag_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_template_result!( "", "{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}", o!({"a": []}) ); assert_template_result!( "1", "{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}", o!({"a": [1]}) ); assert_template_result!(...
code_fim
hard
{ "lang": "rust", "repo": "cobalt-org/liquid-rust", "path": "/tests/conformance_ruby/tags/standard_tag_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn step(&mut self, input: &InputState) -> () { let rot: Basis2<f32> = Rotation2::from_angle(Rad(self.rotation * f32::consts::PI)); for v in self.vertices.iter_mut() { let initial: Vector2<f32> = Vector2 { x: v.pos[0], y: v.pos[1], ...
code_fim
hard
{ "lang": "rust", "repo": "putterson/zoo_spree", "path": "/src/game/minigames/triangle_buffers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { self.data.out = new_target.clone(); } fn render<C>(&self, encoder: &mut Encoder<R, C>) -> () where C: gfx::CommandBuffer<R> { encoder.update_buffer(&self.data.vbuf, &self.vertices, 0) .expect("Failed to update vertex buffer"); encoder.draw(&self.s...
code_fim
hard
{ "lang": "rust", "repo": "putterson/zoo_spree", "path": "/src/game/minigames/triangle_buffers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: putterson/zoo_spree path: /src/game/minigames/triangle_buffers.rs use cgmath::Vector2; use cgmath::{Rotation, Rotation2, Basis2, Basis3, Rotation3, Matrix3}; use cgmath::Rad; use std::f32; use gfx; use gfx::Encoder; use gfx::Factory; use gfx::PipelineState; use gfx::Resources; use gfx::Slice; u...
code_fim
hard
{ "lang": "rust", "repo": "putterson/zoo_spree", "path": "/src/game/minigames/triangle_buffers.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let s = techair::cli::get_inflation_type().unwrap(); println!("{}", s); } ("service-date", _) => { let s = techair::cli::get_service_date().unwrap(); println!("{}", s); } ("operating-modus", _) => { let s = techair::cli::get_operating_modus().unwrap(); prin...
code_fim
hard
{ "lang": "rust", "repo": "victoredwardocallaghan/techair", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: victoredwardocallaghan/techair path: /src/main.rs // Copyright (C) 2020, Edward O'Callaghan. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of ...
code_fim
hard
{ "lang": "rust", "repo": "victoredwardocallaghan/techair", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danielverkamp/crosvm path: /devices/src/pl030.rs // Copyright 2018 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use std::convert::TryFrom; use std::time::SystemTime; use std::time::UNIX_EPOCH; use base::warn; us...
code_fim
hard
{ "lang": "rust", "repo": "danielverkamp/crosvm", "path": "/devices/src/pl030.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let reg_val = u32::from_ne_bytes(*data_array); match info.offset { RTCDR => { warn!("invalid write to read-only RTCDR register"); } RTCMR => { self.match_value = reg_val; // TODO(sonnyrao): here we need to ...
code_fim
hard
{ "lang": "rust", "repo": "danielverkamp/crosvm", "path": "/devices/src/pl030.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let reg_content: u32 = match info.offset { RTCDR => get_epoch_time(), RTCMR => self.match_value, RTCSTAT => self.interrupt_active as u32, RTCLR => { warn!("invalid read of RTCLR register"); 0 } ...
code_fim
hard
{ "lang": "rust", "repo": "danielverkamp/crosvm", "path": "/devices/src/pl030.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jmacmahon/advent-of-code-2016 path: /src/day02/mod.rs const INPUT: &'static [&'static str] = &[ r#"ULL RRDDD LURDL UUUUD"#, r#"LURLDDLDULRURDUDLRULRDLLRURDUDRLLRLRURDRULDLRLRRDDULUDULURULLURLURRRLLDURURLLUURDLLDUUDRRDLDLLRUUDURURRULURUURLDLLLUDDUUDRULLRUDURRLRLLDRRUDULLDUUUDLDLRLLRLULDLRLUDLRRUL...
code_fim
hard
{ "lang": "rust", "repo": "jmacmahon/advent-of-code-2016", "path": "/src/day02/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for dir in line.chars() { let new_pos; match (dir, pos.0, pos.1) { ('U', _, 0) | ('R', 4, _) | ('D', _, 4) | ('L', 0, _) => continue, (_, x, y) => { new_pos = match dir { 'U' => (x, y - 1), 'R' => (x + 1, y...
code_fim
medium
{ "lang": "rust", "repo": "jmacmahon/advent-of-code-2016", "path": "/src/day02/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nymtech/nym path: /common/cosmwasm-smart-contracts/name-service/src/error.rs use cosmwasm_std::{Addr, StdError}; use cw_controllers::AdminError; use nym_contracts_common::signing::verifier::ApiVerifierError; use thiserror::Error; use crate::{Address, NameId, NymName}; #[derive(Error, Debug, Pa...
code_fim
hard
{ "lang": "rust", "repo": "nymtech/nym", "path": "/common/cosmwasm-smart-contracts/name-service/src/error.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: QSCTech/BaseCoreSocialistValues path: /base_core_socialist_values/examples/decoder.rs use base_core_socialist_values::Decoder; use std::io::{self, stdin, stdout}; fn main() -> io::Result<()> { let mut r<|fim_suffix|>(&mut reader, &mut Decoder::new(&mut writer))?; Ok(()) }<|fim_middle|>ea...
code_fim
medium
{ "lang": "rust", "repo": "QSCTech/BaseCoreSocialistValues", "path": "/base_core_socialist_values/examples/decoder.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>(&mut reader, &mut Decoder::new(&mut writer))?; Ok(()) }<|fim_prefix|>// repo: QSCTech/BaseCoreSocialistValues path: /base_core_socialist_values/examples/decoder.rs use base_core_socialist_values::Decoder; use std::io::{self,<|fim_middle|> stdin, stdout}; fn main() -> io::Result<()> { let mut rea...
code_fim
medium
{ "lang": "rust", "repo": "QSCTech/BaseCoreSocialistValues", "path": "/base_core_socialist_values/examples/decoder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Ok(mass) = line { let mut mass = mass.parse::<f32>().unwrap(); loop { mass = calc_fuel_requirement(mass); if mass > 0.0 { total += mass; } else { break; ...
code_fim
hard
{ "lang": "rust", "repo": "ElkeCodes/AdventOfCode2019", "path": "/src/days/day_01.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ElkeCodes/AdventOfCode2019 path: /src/days/day_01.rs use crate::utils; pub fn part_a() -> i32 { let mut total = 0.0; if let Ok(lines) = utils::read_lines("inputs/day01.txt") { for line in lines { if let Ok(mass) = line { total += calc_fuel_requirement...
code_fim
hard
{ "lang": "rust", "repo": "ElkeCodes/AdventOfCode2019", "path": "/src/days/day_01.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>= mass; } else { break; } } } } } total as i32 } fn calc_fuel_requirement(mass: f32) -> f32 { ((mass / 3.0).floor()) - 2.0 }<|fim_prefix|>// repo: ElkeCodes/AdventOfCode2019 path: /src/days/da...
code_fim
hard
{ "lang": "rust", "repo": "ElkeCodes/AdventOfCode2019", "path": "/src/days/day_01.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lfdominguez/elastic path: /src/elastic/src/http/receiver/asynchronous.rs use std::sync::Arc; use futures::{ future::lazy, Future, Poll, Stream, }; use reqwest::r#async::Response as RawResponse; use serde::de::DeserializeOwned; use tokio_threadpool::ThreadPool; use crate::{ ...
code_fim
hard
{ "lang": "rust", "repo": "lfdominguez/elastic", "path": "/src/elastic/src/http/receiver/asynchronous.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> ```no_run # use futures::Future; # use serde_json::Value; # use elastic::prelude::*; # fn main() -> Result<(), Box<::std::error::Error>> { # let client = AsyncClientBuilder::new().build()?; let future = client.request(SimpleSearchRequest::for_index_ty("myindex", "mytype")) ...
code_fim
hard
{ "lang": "rust", "repo": "lfdominguez/elastic", "path": "/src/elastic/src/http/receiver/asynchronous.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> where F: Future<Item = T, Error = Error> + Send + 'static, { IntoResponse { inner: Box::new(fut), } } } impl<T> Future for IntoResponse<T> where T: IsOk + DeserializeOwned + Send + 'static, { type Item = T; type Error = Error; fn poll(&mut ...
code_fim
hard
{ "lang": "rust", "repo": "lfdominguez/elastic", "path": "/src/elastic/src/http/receiver/asynchronous.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[unstable(feature = "crucible_intrinsics", issue = "none")] pub mod concurrency;<|fim_prefix|>// repo: GaloisInc/crucible path: /crux-mir/lib/core/src/crucible/mod.rs //! Contains Crucible intrinsics that are needed within `libcore`. These get reexported from //! `libcrucible` so users have a more cons...
code_fim
medium
{ "lang": "rust", "repo": "GaloisInc/crucible", "path": "/crux-mir/lib/core/src/crucible/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GaloisInc/crucible path: /crux-mir/lib/core/src/crucible/mod.rs //! Contains Crucible intrinsics that are needed within `libcore`. These get reexported from //! `libcrucible` so users have a more consistent API. #[unstable(feature = "crucible_intrinsics", issue = "none")] pub mod any; <|fim_su...
code_fim
medium
{ "lang": "rust", "repo": "GaloisInc/crucible", "path": "/crux-mir/lib/core/src/crucible/mod.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>rd); } else { panic!("No more cards in deck"); } } else { panic!("No such player"); } } pub fn play(&mut self, player: usize, card: usize) { let &mut Game{ref mut pile, ref mut players, ..} = self; if let Some(ref ...
code_fim
hard
{ "lang": "rust", "repo": "LFalch/arsehole", "path": "/src/game.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LFalch/arsehole path: /src/game.rs use super::Card; use rand::{thread_rng, Rng}; #[derive(Debug)] pub struct Game<Name> { pub deck: Vec<Card>, pub pile: Vec<Card>, pub players: Vec<Player<Name>>, } impl<Name> Game<Name> { pub fn new() -> Self { let deck = (0..52).map(|...
code_fim
hard
{ "lang": "rust", "repo": "LFalch/arsehole", "path": "/src/game.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SuperCleanMe/Curio path: /src/lib.rs //! # Curio //! //! A blazing fast HTTP client. //! //! ## Examples: //! //! __examples below assume you are importing the `prelude` module as a base dependancy.__ //! //! # GET content from a url: //! This one is just a simple GET request, no headers necessa...
code_fim
hard
{ "lang": "rust", "repo": "SuperCleanMe/Curio", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>>> { //! // lets define a string containing the content body. //! let mut post_body = "This is some example content to POST"; //! //! // in this line we convert the string into a format accepted by the `set_body` method. //! // this method accepts anything which can be converted into a str...
code_fim
hard
{ "lang": "rust", "repo": "SuperCleanMe/Curio", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub fn len(&self) -> usize { self.len } } impl Drop for MmapInner { fn drop(&mut self) { let alignment = self.ptr as usize % allocation_granularity(); unsafe { let ptr = self.ptr.offset(-(alignment as isize)); assert!( ...
code_fim
hard
{ "lang": "rust", "repo": "godaddy-icfp/icfp-2020", "path": "/vendor/memmap/src/windows.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: godaddy-icfp/icfp-2020 path: /vendor/memmap/src/windows.rs use std::fs::File; use std::os::raw::c_void; use std::os::windows::io::{AsRawHandle, RawHandle}; use std::{io, mem, ptr}; use winapi::shared::basetsd::SIZE_T; use winapi::shared::minwindef::DWORD; use winapi::um::handleapi::{CloseHandle...
code_fim
hard
{ "lang": "rust", "repo": "godaddy-icfp/icfp-2020", "path": "/vendor/memmap/src/windows.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn fallback_fn() -> impl Responder { NamedFile::open("./client/build/index.html") }<|fim_prefix|>// repo: shaoweigege/cryptgeon path: /src/client.rs use actix_files::{Files, NamedFile}; use actix_web::{web, Responder}; <|fim_middle|>pub fn init(cfg: &mut web::ServiceConfig) { cfg.service(F...
code_fim
medium
{ "lang": "rust", "repo": "shaoweigege/cryptgeon", "path": "/src/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shaoweigege/cryptgeon path: /src/client.rs use actix_files::{Files, NamedFile}; use actix_web::{web, Responder}; <|fim_suffix|>pub async fn fallback_fn() -> impl Responder { NamedFile::open("./client/build/index.html") }<|fim_middle|>pub fn init(cfg: &mut web::ServiceConfig) { cfg.service(F...
code_fim
medium
{ "lang": "rust", "repo": "shaoweigege/cryptgeon", "path": "/src/client.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: catleeball/image-orientation-sorter path: /src/main.rs #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; extern crate stderrlog; use aho_corasick::{AhoCorasick, AhoCorasickBuilder}; use arraystring::{ArrayString, typenum::U4}; use image::image_dimensions; use std::cmp::Order...
code_fim
hard
{ "lang": "rust", "repo": "catleeball/image-orientation-sorter", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn test_opts() -> Opt { Opt { input_dir: tempdir().unwrap().path().to_path_buf(), output_dir: tempdir().unwrap().path().to_path_buf(), recursive: false, rename: false, verbose: 5, quiet: false, ov...
code_fim
hard
{ "lang": "rust", "repo": "catleeball/image-orientation-sorter", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Recursive walk. Expect 15 images in dir tree. opts.recursive = true; let src_paths = image_paths(&opts); debug!("[test_image_paths; recursive]Src paths: {:#?}", src_paths); assert_eq!(src_paths.len(), 15); } #[test] fn test_get_dsts() { i...
code_fim
hard
{ "lang": "rust", "repo": "catleeball/image-orientation-sorter", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// This register is used to activate the reset of the corresponding peripheral. Writing has no effect, reading will return the effective values of the corresponding bits. Writing a activates the reset of the corresponding peripheral. If TZEN = , this register can only be modified in secure mode. pub mod ...
code_fim
hard
{ "lang": "rust", "repo": "adamgreig/stm32ral", "path": "/src/stm32mp/peripherals/rcc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adamgreig/stm32ral path: /src/stm32mp/peripherals/rcc.rs d-only values (empty) pub mod R {} /// Write-only values (empty) pub mod W {} /// Read-write values (empty) pub mod RW {} } /// VREFEN pub mod VREFEN { /// Offset (13 bits) ...
code_fim
hard
{ "lang": "rust", "repo": "adamgreig/stm32ral", "path": "/src/stm32mp/peripherals/rcc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// LSERDYIE pub mod LSERDYIE { /// Offset (1 bits) pub const offset: u32 = 1; /// Mask (1 bit: 1 << 1) pub const mask: u32 = 1 << offset; /// Read-only values (empty) pub mod R {} /// Write-only values (empty) pub mod W {} //...
code_fim
hard
{ "lang": "rust", "repo": "adamgreig/stm32ral", "path": "/src/stm32mp/peripherals/rcc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[async_std::main] async fn main() -> Result<(), Error> { let stream = mdns::discover::all(SERVICE_NAME, Duration::from_secs(15))?.listen(); pin_mut!(stream); while let Some(Ok(response)) = stream.next().await { let addr = response.ip_addr(); if let Some(addr) = addr { ...
code_fim
medium
{ "lang": "rust", "repo": "dave-tucker/mdns", "path": "/examples/http_discovery.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dave-tucker/mdns path: /examples/http_discovery.rs use futures_util::{pin_mut, stream::StreamExt}; use mdns::Error; use std::time::Duration; <|fim_suffix|>#[async_std::main] async fn main() -> Result<(), Error> { let stream = mdns::discover::all(SERVICE_NAME, Duration::from_secs(15))?.liste...
code_fim
medium
{ "lang": "rust", "repo": "dave-tucker/mdns", "path": "/examples/http_discovery.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chemouna/AlgorithmsRust path: /algorithms/src/main.rs #[cfg(test)] #[macro_use] extern crate quickcheck; /*fn main() { let arr1: [f64; 9] = [-2.0, 1.0, -3.0, 4.0, -1.0, 2.0, 1.0, -5.0, 4.0]; let (max, start, end) = max_subarray_kadane(&arr1); println!("{}, {}, {}", max, start, end)...
code_fim
hard
{ "lang": "rust", "repo": "chemouna/AlgorithmsRust", "path": "/algorithms/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if arr.len() == 0 { panic!("Error: empty array") } let mut max_ending_here: f64 = arr[0]; let mut max_so_far: f64 = arr[0]; let mut start = 0; let mut end = 0; let mut potential_start = 0; for i in 0..arr.len() { if ...
code_fim
medium
{ "lang": "rust", "repo": "chemouna/AlgorithmsRust", "path": "/algorithms/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AntonZelenin/rust-physics-engine path: /src/particle/collision/contact_resolver.rs extern crate ordered_float; use crate::particle::collision::contact::Contact; use crate::particle::particle_trait::ParticleTrait; use crate::types::Real; use ordered_float::OrderedFloat; <|fim_suffix|> pub fn...
code_fim
hard
{ "lang": "rust", "repo": "AntonZelenin/rust-physics-engine", "path": "/src/particle/collision/contact_resolver.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_iterations(&mut self, iterations: u32) { self.velocity_iterations = iterations; self.position_iterations = iterations; } }<|fim_prefix|>// repo: AntonZelenin/rust-physics-engine path: /src/particle/collision/contact_resolver.rs extern crate ordered_float; use crate::pa...
code_fim
hard
{ "lang": "rust", "repo": "AntonZelenin/rust-physics-engine", "path": "/src/particle/collision/contact_resolver.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> where I: Iterator<Item = u8> { skip_newline(bs); match bs.next() { Some(b'>') => (), Some(_) => return Err(io::Error::new(io::ErrorKind::InvalidData, "Labels should start with '>'")), None => return Ok(vec![]), } let...
code_fim
hard
{ "lang": "rust", "repo": "gyk/rosalind", "path": "/gc/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn next_label<I>(bs: &mut Peekable<I>) -> Result<Vec<u8>> where I: Iterator<Item = u8> { skip_newline(bs); match bs.next() { Some(b'>') => (), Some(_) => return Err(io::Error::new(io::ErrorKind::InvalidData, "Labels should start with...
code_fim
hard
{ "lang": "rust", "repo": "gyk/rosalind", "path": "/gc/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gyk/rosalind path: /gc/src/main.rs use std::io::{self, stdin, Read, Result}; use std::iter::Peekable; #[inline] fn is_nucleobase(b: u8) -> bool { b == b'A' || b == b'C' || b == b'G' || b == b'T' } #[inline] fn is_gc(b: u8) -> bool { b == b'G' || b == b'C' } #[inline] fn is...
code_fim
hard
{ "lang": "rust", "repo": "gyk/rosalind", "path": "/gc/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Add an anchor to the button. pub fn with_anchor(mut self, anchor: Anchor) -> Self { self.anchor = anchor; self } /// Stretch the button. pub fn with_stretch(mut self, stretch: Stretch) -> Self { self.stretch = stretch; self } /// This will ...
code_fim
hard
{ "lang": "rust", "repo": "MirecIT/amethyst", "path": "/amethyst_ui/src/label.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MirecIT/amethyst path: /amethyst_ui/src/label.rs use std::marker::PhantomData; use amethyst_assets::{register_asset_type, Asset, AssetProcessorSystem, Handle}; use amethyst_core::{ ecs::*, transform::{Parent, Transform}, }; use crate::{ define_widget, Anchor, FontAsset, LineMode, S...
code_fim
hard
{ "lang": "rust", "repo": "MirecIT/amethyst", "path": "/amethyst_ui/src/label.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> text_entry.add_component( UiTransform::new( format!("{}_label", id), self.anchor, Anchor::Middle, self.x, self.y, self.z, self.width, self.height, ...
code_fim
hard
{ "lang": "rust", "repo": "MirecIT/amethyst", "path": "/amethyst_ui/src/label.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xpeerchain/xpeerchain path: /network/src/protocols/health_checker/test.rs // Copyright (c) The XPeer Core Contributors // SPDX-License-Identifier: Apache-2.0 use super::*; use crate::{common::NegotiatedSubstream, peer_manager::PeerManagerRequest}; use futures::future::{FutureExt, TryFutureExt};...
code_fim
hard
{ "lang": "rust", "repo": "xpeerchain/xpeerchain", "path": "/network/src/protocols/health_checker/test.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> peer_mgr_notifs_tx .send(PeerManagerNotification::NewPeer( peer_id, peer_address.clone(), )) .await .unwrap(); // Trigger ping to a peer. This should ping the newly added peer. ticker_tx.send(()).await...
code_fim
hard
{ "lang": "rust", "repo": "xpeerchain/xpeerchain", "path": "/network/src/protocols/health_checker/test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Health checker should request for a new substream. let listener_substream = expect_open_substream(peer_id, &mut peer_mgr_reqs_rx).await; // Health checker should send a ping request which fails. expect_ping_send_notok(listener_substream).await; // Health checke...
code_fim
hard
{ "lang": "rust", "repo": "xpeerchain/xpeerchain", "path": "/network/src/protocols/health_checker/test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // we can also iterate over mutable references to each element in a mutable vector in order to // make changes to all the elements let mut v4 = vec![100, 32, 57]; for i in &mut v { *i += 50; } // using an enum to store multiple types enum SpreadsheetCell { Int(...
code_fim
hard
{ "lang": "rust", "repo": "collinprince/rust-book", "path": "/projects/vectors/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: collinprince/rust-book path: /projects/vectors/src/main.rs fn main() { // create empty array of ints let mut v: Vec<i32> = Vec::new(); // create array of ints (implied i32 by default) let mut v2 = vec![1, 2, 3]; // pushing to a vector v.push(5); v.push(6); v.pus...
code_fim
hard
{ "lang": "rust", "repo": "collinprince/rust-book", "path": "/projects/vectors/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // mutable reference rules are still applied to vectors let first: &i32 = &v[0]; v.push(10); // if we uncomment the below line, then there will be an error since we hold onto the immutable // ref for first in addition to the mutable reference that is borrowed when we push 10 // pri...
code_fim
hard
{ "lang": "rust", "repo": "collinprince/rust-book", "path": "/projects/vectors/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MattesWhite/indexed-hash-set path: /src/internal_ref.rs use std::borrow::Borrow; use std::convert::AsRef; use std::fmt; use std::hash::{Hash, Hasher}; use std::ptr::NonNull; /// Reference to an element of the set. Only used internal. /// /// This is used for building a self-referential map insi...
code_fim
hard
{ "lang": "rust", "repo": "MattesWhite/indexed-hash-set", "path": "/src/internal_ref.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { self.0.as_ref() } } } impl<T> Hash for InternalRef<T> where T: Hash, { /// Hashes the referenced `T` just like a normal reference. fn hash<H: Hasher>(&self, state: &mut H) { self.as_ref().hash(state) } } /// A helper struct to allow using `InternalRef` as key...
code_fim
hard
{ "lang": "rust", "repo": "MattesWhite/indexed-hash-set", "path": "/src/internal_ref.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>== sandwiches.length` // * `sandwiches[i]` is `0` or `1`. // * `students[i]` is `0` or `1`. pub fn count_students(students: Vec<i32>, sandwiches: Vec<i32>) -> i32 { let mut map = students .iter() .fold(std::collections::HashMap::new(), |mut map, &student| { *map.entry(...
code_fim
hard
{ "lang": "rust", "repo": "gengjiawen/leetcode", "path": "/Array/_1700_number_of_students_unable_to_eat_lunch.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gengjiawen/leetcode path: /Array/_1700_number_of_students_unable_to_eat_lunch.rs // https://leetcode.com/problems/number-of-students-unable-to-eat-lunch // // The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers `0` and `1` respectively. All students ...
code_fim
hard
{ "lang": "rust", "repo": "gengjiawen/leetcode", "path": "/Array/_1700_number_of_students_unable_to_eat_lunch.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ront student leaves the top sandwich and returns to the end of the line making students = [1,1,0]. // - Front student takes the top sandwich and leaves the line making students = [1,0] and sandwiches = [0,1]. // - Front student leaves the top sandwich and returns to the end of the line making students = [...
code_fim
hard
{ "lang": "rust", "repo": "gengjiawen/leetcode", "path": "/Array/_1700_number_of_students_unable_to_eat_lunch.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: atheriel/grunge path: /examples/doc-images.rs /* This file is part of grunge, a coherent noise generation library. */ extern crate grunge; extern crate image; use std::default::Default; use std::io::File; use image::GenericImage; <|fim_suffix|>fn create_png(noise: &Modifiable, filename: &...
code_fim
medium
{ "lang": "rust", "repo": "atheriel/grunge", "path": "/examples/doc-images.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Write the image to disk let _ = image::ImageLuma8(imbuf).save(file, image::PNG); } fn main() { let pink = PinkNoise { seed: 1u, frequency: 0.01, .. Default::default() }; let billow = BillowNoise { seed: 1u, frequency: 0.01, .. Default::default() }; let ridged = RidgedMultifractalNo...
code_fim
hard
{ "lang": "rust", "repo": "atheriel/grunge", "path": "/examples/doc-images.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut up = true; loop { for i in 0..0xff { // Fade up and down let index = if up { i } else { 0xfe - i } as u16; // Scale brightness quadratic instead of linearly let duty_cycle = ((index * index) >> 8) + 1; led.set_duty(duty_cy...
code_fim
hard
{ "lang": "rust", "repo": "Rahix/leonardo-examples", "path": "/src/pwm.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }