text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> ips_and_streams_treeview;
mod messages_treeview;
mod preferences;
mod recent_file_item;
pub mod win;<|fim_prefix|>// repo: therustmonk/hotwire path: /src/widgets/mod.rs
pub mod comm_info_header;
pub mod comm_remote_serv<|fim_middle|>er;
mod comm_target_card;
mod headerbar_search;
mod | code_fim | easy | {
"lang": "rust",
"repo": "therustmonk/hotwire",
"path": "/src/widgets/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self.transport_side
}
fn getParams(&mut self) -> &mut CodecConstructorParameters {
&mut self.params
}
fn new(
host_side: HostSide,
transport_side: TransportSide,
params: CodecConstructorParameters,
) -> Box<dyn Codec> {
let tag: Stri... | code_fim | hard | {
"lang": "rust",
"repo": "tejbabu91/apama_connectivity_rust",
"path": "/examples/diag_codec/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tejbabu91/apama_connectivity_rust path: /examples/diag_codec/src/lib.rs
use rust_ap_connectivity::*;
pub struct DiagCodec {
host_side: HostSide,
transport_side: TransportSide,
params: CodecConstructorParameters,
tag: String,
}
impl Codec for DiagCodec {
fn start(&mut self) ... | code_fim | medium | {
"lang": "rust",
"repo": "tejbabu91/apama_connectivity_rust",
"path": "/examples/diag_codec/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_3() {
assert_eq!(Solution::fib(3), 2);
}
#[test]
fn test_4() {
assert_eq!(Solution::fib(4), 3);
}
}<|fim_prefix|>// repo: hencrice/leetcode-rust path: /src/q00509_fibonacci_number.rs
pub struct Solution {}
impl Solution {
pub fn fib(n: i32) ->... | code_fim | hard | {
"lang": "rust",
"repo": "hencrice/leetcode-rust",
"path": "/src/q00509_fibonacci_number.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hencrice/leetcode-rust path: /src/q00509_fibonacci_number.rs
pub struct Solution {}
impl Solution {
pub fn fib(n: i32) -> i32 {
if n == 1 {
1
} else if n == 0 {
0
} else {
let (mut prev_1, mut prev_2) = (1, 0);
for _ in... | code_fim | medium | {
"lang": "rust",
"repo": "hencrice/leetcode-rust",
"path": "/src/q00509_fibonacci_number.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn new_from_rgb() {
let color = Color::new_from_rgb(253, 185, 200);
assert_eq!(color.value, "rgb(253,185,200)".to_string());
}
}<|fim_prefix|>// repo: limpidchart/lc-render path: /src/color.rs
pub const COLOR_HEX_BLUE_1: &str = "#0e3569";
pub const COLOR_HEX_BLUE_2: &s... | code_fim | hard | {
"lang": "rust",
"repo": "limpidchart/lc-render",
"path": "/src/color.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::new_from_hex(COLOR_HEX_BLUE_2)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn new_from_hex() {
let color = Color::new_from_hex(COLOR_HEX_GREEN_5);
assert_eq!(color.value, COLOR_HEX_GREEN_5);
}
#[test]
fn new_from_rgb() {
let color... | code_fim | hard | {
"lang": "rust",
"repo": "limpidchart/lc-render",
"path": "/src/color.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: limpidchart/lc-render path: /src/color.rs
pub const COLOR_HEX_BLUE_1: &str = "#0e3569";
pub const COLOR_HEX_BLUE_2: &str = "#1960b2";
pub const COLOR_HEX_BLUE_3: &str = "#3a88e2";
pub const COLOR_HEX_BLUE_4: &str = "#5095e5";
pub const COLOR_HEX_BLUE_5: &str = "#a5c9f2";
<|fim_suffix|> w... | code_fim | hard | {
"lang": "rust",
"repo": "limpidchart/lc-render",
"path": "/src/color.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut auth_manager = data.auth_manager.write().await;
let token = auth_manager.get_or_generate_token_for_user(user_info);
HttpResponse::TemporaryRedirect().header(header::LOCATION, format!("{}?token={}", data.frontend_url, token)).finish()
}
#[derive(Deserialize)]
pub struct WebSocketQuery... | code_fim | hard | {
"lang": "rust",
"repo": "KrekBuk/chess-rs",
"path": "/src/http/http_server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KrekBuk/chess-rs path: /src/http/http_server.rs
use std::sync::Arc;
use actix_cors::Cors;
use actix_session::{CookieSession, Session};
use actix_web::cookie::SameSite;
use actix_web::{get, http::header, web, App, HttpRequest, HttpResponse, HttpServer};
use actix_web_actors::ws;
use oauth2::basi... | code_fim | hard | {
"lang": "rust",
"repo": "KrekBuk/chess-rs",
"path": "/src/http/http_server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: robbieaverill/exercism-rs path: /grains/src/lib.rs
/**
* Calculate how many grains would be given for the provided chess board square
*/
pub fn square(square: u32, ) -> u64 {
get_grains(square)
}
/**
* Calculates the sum of how many grains would be on an entire chess board
*/
pub fn tot... | code_fim | medium | {
"lang": "rust",
"repo": "robbieaverill/exercism-rs",
"path": "/grains/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Idiot proofing
if square > 64 || square < 1 {
panic!("Square must be between 1 and 64");
}
let mut grains: u64 = 0;
let mut last_grains: u64 = 1;
for _ in 1..square + 1 {
grains += last_grains;
last_grains = grains;
}
grains
}<|fim_prefix|>// r... | code_fim | hard | {
"lang": "rust",
"repo": "robbieaverill/exercism-rs",
"path": "/grains/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in 1..square + 1 {
grains += last_grains;
last_grains = grains;
}
grains
}<|fim_prefix|>// repo: robbieaverill/exercism-rs path: /grains/src/lib.rs
/**
* Calculate how many grains would be given for the provided chess board square
*/
pub fn square(square: u32, ) -> u6... | code_fim | hard | {
"lang": "rust",
"repo": "robbieaverill/exercism-rs",
"path": "/grains/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xemwebe/gurufocus_api path: /examples/04_quotes.rs
use gurufocus_api as gfapi;
use std::env;
type QuoteList = Vec<gfapi::Quote>;
<|fim_suffix|> let prices: QuoteList = serde_json::from_value(prices).unwrap();
println!("Compare latest quotes of Apple stock prices and three different exch... | code_fim | hard | {
"lang": "rust",
"repo": "xemwebe/gurufocus_api",
"path": "/examples/04_quotes.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let prices: QuoteList = serde_json::from_value(prices).unwrap();
println!("Compare latest quotes of Apple stock prices and three different exchanges:");
println!("{:#?}", prices);
}<|fim_prefix|>// repo: xemwebe/gurufocus_api path: /examples/04_quotes.rs
use gurufocus_api as gfapi;
use std::e... | code_fim | hard | {
"lang": "rust",
"repo": "xemwebe/gurufocus_api",
"path": "/examples/04_quotes.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn wrap_text(&self, s: &str, width: u32) -> String {
let mut out = String::with_capacity(s.len());
let size = self.size as f32;
let width = width as f32;
let mut w = 0.0;
for c in s.chars() {
let chw = (self.font.get(c).advance * size).x;
w += chw;
if w > width... | code_fim | hard | {
"lang": "rust",
"repo": "dopitz/vulkanism",
"path": "/nobs-imgui/nobs-imgui-font/src/typeset.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dopitz/vulkanism path: /nobs-imgui/nobs-imgui-font/src/typeset.rs
use super::Font;
use std::sync::Arc;
use vkm;
pub trait FontChar {
fn set_position(&mut self, p: vkm::Vec2f);
fn set_size(&mut self, s: vkm::Vec2f);
fn set_tex(&mut self, t00: vkm::Vec2f, t11: vkm::Vec2f);
}
#[derive(Clone... | code_fim | hard | {
"lang": "rust",
"repo": "dopitz/vulkanism",
"path": "/nobs-imgui/nobs-imgui-font/src/typeset.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andete/atsam4lc8c path: /src/spi/csr/mod.rs
fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
#[doc = r" Writes to the register"]
#[inline]
pub fn write<F>(&self, f: F)
where
F: FnOnce(&mut W) -> &mut W,
{
let mut w = W:... | code_fim | hard | {
"lang": "rust",
"repo": "andete/atsam4lc8c",
"path": "/src/spi/csr/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>mains active until a new transfer isrequested on a different chip select."]
_1,
}
impl CSAATW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline]
pub fn _bits(&self) -> bool {
match *self {
CSAATW::_0 => false,
CSAATW::_1 => true,
}
}
}
#[doc =... | code_fim | hard | {
"lang": "rust",
"repo": "andete/atsam4lc8c",
"path": "/src/spi/csr/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andete/atsam4lc8c path: /src/spi/csr/mod.rs
NCPHAR::_1 => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline]
pub fn _from(value: bool) -> NCPHAR {
match value {
false => NCPHAR::_0,
true => NCPHAR::_1,
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "andete/atsam4lc8c",
"path": "/src/spi/csr/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ix = if record[2].to_string() == "M" { MAN } else { WOMAN };
let name = record[0].to_string();
let last_name = record[1].to_string().to_lowercase().chars().filter(|c| c.is_alphabetic() ).collect::<String>();
let (last_name1, last_name2) = (&last_name[..last_name.len()-... | code_fim | hard | {
"lang": "rust",
"repo": "KFBI1706/kodekalender",
"path": "/2019/day18/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KFBI1706/kodekalender path: /2019/day18/main.rs
extern crate csv;
use std::collections::HashMap;
use std::fs;
use std::fs::File;
const MAN: usize = 0;
const WOMAN: usize = 1;
const LASTNAME1: usize = 2;
const LASTNAME2: usize = 3;
const ALPHABET:&str = "abcdefghijklmnopqrstuvwxyz";
fn main() {... | code_fim | hard | {
"lang": "rust",
"repo": "KFBI1706/kodekalender",
"path": "/2019/day18/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BrainiumLLC/cargo-mobile path: /src/util/ln.rs
use std::{
fmt::{self, Display},
path::{Path, PathBuf},
};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum LinkType {
Hard,
Symbolic,
}
impl Display for LinkType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result ... | code_fim | hard | {
"lang": "rust",
"repo": "BrainiumLLC/cargo-mobile",
"path": "/src/util/ln.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub struct Error {
link_type: LinkType,
force: Clobber,
source: PathBuf,
target: PathBuf,
target_style: TargetStyle,
cause: ErrorCause,
}
impl Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
... | code_fim | hard | {
"lang": "rust",
"repo": "BrainiumLLC/cargo-mobile",
"path": "/src/util/ln.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug)]
pub struct Call<'a> {
link_type: LinkType,
force: Clobber,
source: &'a Path,
target: &'a Path,
target_style: TargetStyle,
}
impl<'a> Call<'a> {
pub fn new(
link_type: LinkType,
force: Clobber,
source: &'a Path,
target: &'a Pa... | code_fim | hard | {
"lang": "rust",
"repo": "BrainiumLLC/cargo-mobile",
"path": "/src/util/ln.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>PR::LOW
}
}
#[doc = "Possible values of the field `CC1NE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum CC1NER {
#[doc = "Off"] DISABLED,
#[doc = "On"] ENABLED,
}
impl CC1NER {
#[doc = r" Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) ->... | code_fim | hard | {
"lang": "rust",
"repo": "creationix/stm32f042x",
"path": "/stm32f0x2/src/tim1/ccer/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: creationix/stm32f042x path: /stm32f0x2/src/tim1/ccer/mod.rs
mpl<'a> _CC3NEW<'a> {
#[doc = r" Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: CC3NEW) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "Off"]
#... | code_fim | hard | {
"lang": "rust",
"repo": "creationix/stm32f042x",
"path": "/stm32f0x2/src/tim1/ccer/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: creationix/stm32f042x path: /stm32f0x2/src/tim1/ccer/mod.rs
D`"]
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == CC2NER::DISABLED
}
#[doc = "Checks if the value of the field is `ENABLED`"]
#[inline(always)]
pub fn is_enabled(&self) -> bool {
... | code_fim | hard | {
"lang": "rust",
"repo": "creationix/stm32f042x",
"path": "/stm32f0x2/src/tim1/ccer/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let s1 = String::from("Hello");
let s2 = &s1;
let s3 = prend_et_rend(String::from("world"));
print_str(&s2);
print_str(&s2);
print_str(&s1);
print_str(&s1);
print_str(&s3);
print_str(&s3);
}<|fim_prefix|>// repo: ljahier/learn-rust path: /borrowing/src/main.rs
fn prin... | code_fim | easy | {
"lang": "rust",
"repo": "ljahier/learn-rust",
"path": "/borrowing/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print_str(&s2);
print_str(&s2);
print_str(&s1);
print_str(&s1);
print_str(&s3);
print_str(&s3);
}<|fim_prefix|>// repo: ljahier/learn-rust path: /borrowing/src/main.rs
fn print_str(str: &String) -> () {
println!("{}", str);
}
fn prend_et_rend(str: String) -> String {
str
... | code_fim | medium | {
"lang": "rust",
"repo": "ljahier/learn-rust",
"path": "/borrowing/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ljahier/learn-rust path: /borrowing/src/main.rs
fn print_str(str: &String) -> () {
println!("{}", str);
}
<|fim_suffix|> str
}
fn main() {
let s1 = String::from("Hello");
let s2 = &s1;
let s3 = prend_et_rend(String::from("world"));
print_str(&s2);
print_str(&s2);
... | code_fim | easy | {
"lang": "rust",
"repo": "ljahier/learn-rust",
"path": "/borrowing/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matter-labs/bellman path: /src/sonic/srs/srs.rs
use crate::pairing::ff::{Field, PrimeField};
use crate::pairing::{CurveAffine, CurveProjective, Engine, Wnaf};
use std::io::{self, Read, Write};
use std::sync::Arc;
use byteorder::{BigEndian, WriteBytesExt, ReadBytesExt};
#[derive(Clone, Eq)]
pub... | code_fim | hard | {
"lang": "rust",
"repo": "matter-labs/bellman",
"path": "/src/sonic/srs/srs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let read_g2 = |reader: &mut R| -> io::Result<E::G2Affine> {
let mut repr = <E::G2Affine as CurveAffine>::Uncompressed::empty();
reader.read_exact(repr.as_mut())?;
if checked {
repr
.into_affine()
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "matter-labs/bellman",
"path": "/src/sonic/srs/srs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.check_integrity();
other.check_integrity();
let mut sum = self.x - other.x;
if sum < 0 { sum += MOD; }
ModInt { x: sum }
}
}
impl Mul for ModInt {
type Output = Self;
fn mul(self, other: Self) -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "sogapalag/contest",
"path": "/aizu/2556.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sogapalag/contest path: /aizu/2556.rs
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok().unwrap();
ret
}
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "sogapalag/contest",
"path": "/aizu/2556.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if c == [0] {
return calc_zero(v);
}
let n = v.len();
let m = c.len();
if n < m { return ModInt::new(0); }
let mut ans = ModInt::new(0);
let mut acc = vec![ModInt::new(0); n + 1];
for i in (0 .. n).rev() {
acc[i] = ModInt::new(10) * acc[i + 1] + ModInt::new(... | code_fim | hard | {
"lang": "rust",
"repo": "sogapalag/contest",
"path": "/aizu/2556.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> App::build()
.add_plugins(DefaultPlugins)
.add_plugin(plugins::GreeterPlugin)
.run();
}<|fim_prefix|>// repo: Noah2610/hello-bevy path: /src/main.rs
extern crate bevy;
mod components;
mod plugins;
mod resources;
mod systems;
<|fim_middle|>use bevy::app::App;
use bevy::Defaul... | code_fim | easy | {
"lang": "rust",
"repo": "Noah2610/hello-bevy",
"path": "/src/main.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Noah2610/hello-bevy path: /src/main.rs
extern crate bevy;
mod components;
mod plugins;
mod resources;
mod systems;
use bevy::app::App;
use bevy::DefaultPlugins;
<|fim_suffix|> App::build()
.add_plugins(DefaultPlugins)
.add_plugin(plugins::GreeterPlugin)
.run();
}<|f... | code_fim | easy | {
"lang": "rust",
"repo": "Noah2610/hello-bevy",
"path": "/src/main.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut record = match records_by_benchmark.get_mut(&benchmark_name) {
Some(record) => record.clone(),
None => CsvRecord {
benchmark_name: benchmark_name.clone(),
llcpp: None,
hlcpp: None,
rust: None,
... | code_fim | hard | {
"lang": "rust",
"repo": "xyuan/fuchsia",
"path": "/src/tests/benchmarks/fidl/runner/src/output.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xyuan/fuchsia path: /src/tests/benchmarks/fidl/runner/src/output.rs
// Copyright 2020 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::cmd::BenchmarkResult;
use crate::label::{LabelSpec, ... | code_fim | hard | {
"lang": "rust",
"repo": "xyuan/fuchsia",
"path": "/src/tests/benchmarks/fidl/runner/src/output.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let match_spec = LabelSpec::new(vec![LabelSpecPart::Binding, LabelSpecPart::Any]);
let binding_spec = LabelSpec::new(vec![LabelSpecPart::Binding]);
let any_spec = LabelSpec::new(vec![LabelSpecPart::Any]);
let mut records_by_benchmark: BTreeMap<String, CsvRecord> = BTreeMap::new();
for ... | code_fim | hard | {
"lang": "rust",
"repo": "xyuan/fuchsia",
"path": "/src/tests/benchmarks/fidl/runner/src/output.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CEED/libCEED path: /examples/rust/ex2-surface/src/opt.rs
// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
// All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
//
// SPDX-License-Identifier: BSD-2-Clause
//
// This file ... | code_fim | medium | {
"lang": "rust",
"repo": "CEED/libCEED",
"path": "/examples/rust/ex2-surface/src/opt.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>// ----------------------------------------------------------------------------
// Command line arguments
// ----------------------------------------------------------------------------
#[derive(Debug, Parser)]
#[command(
name = "libCEED Rust Example 2 - Surface Area",
about = "This example illust... | code_fim | medium | {
"lang": "rust",
"repo": "CEED/libCEED",
"path": "/examples/rust/ex2-surface/src/opt.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn parse_shift_expr(&mut self) -> ASTExpr {
let left = match self.tokenizer.get_current_token() {
Token::PLUS
| Token::MINUS
| Token::TILDE
| Token::LPAREN
| Token::LBRACE
| Token::LBRACKET
| Token::ID(_)
... | code_fim | hard | {
"lang": "rust",
"repo": "xecua/mini-py",
"path": "/src/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.eat(&Token::DEF);
let name = self.eat_id();
let arguments = match self.tokenizer.get_current_token() {
Token::LPAREN => self.parse_parameters(),
_ => self.error(format!("SyntaxError: unexpected token")),
};
self.eat(&Token::COLON);
... | code_fim | hard | {
"lang": "rust",
"repo": "xecua/mini-py",
"path": "/src/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xecua/mini-py path: /src/parser.rs
e_arglist();
self.eat(&Token::RPAREN);
atom = ASTExpr::Call(Box::new(atom), args);
}
Token::LBRACKET => {
// list/set/dict subscription
self.eat(&Tok... | code_fim | hard | {
"lang": "rust",
"repo": "xecua/mini-py",
"path": "/src/parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(result)
}
// Queues an update to the table root
pub(crate) fn stage_update_table_root(
&mut self,
name: &str,
table_root: Option<(PageNumber, Checksum)>,
) {
self.pending_table_updates
.insert(name.to_string(), table_root);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "cberner/redb",
"path": "/src/tree_store/table_tree.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(data.len() >= 8);
// Set the length to zero
data[..8].fill(0);
}
fn from_bytes_mut(data: &mut [u8]) -> &mut Self::BaseRefType {
unsafe { mem::transmute(data) }
}
}
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug)]
pub(crate) enum TableType {
Norma... | code_fim | hard | {
"lang": "rust",
"repo": "cberner/redb",
"path": "/src/tree_store/table_tree.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cberner/redb path: /src/tree_store/table_tree.rs
where
Self: 'a;
type AsBytes<'a> = &'a [u8]
where
Self: 'a;
fn fixed_width() -> Option<usize> {
None
}
fn from_bytes<'a>(data: &'a [u8]) -> Self::SelfType<'a>
where
Self: 'a,
... | code_fim | hard | {
"lang": "rust",
"repo": "cberner/redb",
"path": "/src/tree_store/table_tree.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mbillingr/learning path: /growing-oo-software-guided-by-tests/rust/auction_sniper/src/testing/message_listener.rs
use std::sync::mpsc::Receiver;
use std::time::Duration;
pub struct SingleMessageListener<T> {
rx: Receiver<T>,
}
<|fim_suffix|> pub fn receives_a_message(&self) {
as... | code_fim | medium | {
"lang": "rust",
"repo": "mbillingr/learning",
"path": "/growing-oo-software-guided-by-tests/rust/auction_sniper/src/testing/message_listener.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> SingleMessageListener<T> {
pub fn new(rx: Receiver<T>) -> Self {
SingleMessageListener { rx }
}
pub fn receives_a_message(&self) {
assert!(self.rx.recv_timeout(Duration::from_secs(50)).is_ok())
}
}<|fim_prefix|>// repo: mbillingr/learning path: /growing-oo-softwar... | code_fim | medium | {
"lang": "rust",
"repo": "mbillingr/learning",
"path": "/growing-oo-software-guided-by-tests/rust/auction_sniper/src/testing/message_listener.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn keyboard(
keyboard_input: Res<Input<KeyCode>>,
mut profiler_enabled: ResMut<ProfilerEnabled>,
mut profiler_gui_enabled: ResMut<ProfilerGuiEnabled>,
) {
if keyboard_input.just_pressed(KeyCode::I) {
profiler_enabled.0 = !profiler_enabled.0;
}
if keyboard_input.just... | code_fim | hard | {
"lang": "rust",
"repo": "drhaynes/hands-on-rust",
"path": "/src/profiler_plugin.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: drhaynes/hands-on-rust path: /src/profiler_plugin.rs
use bevy::prelude::*;
use bevy_egui::EguiContext;
struct ProfilerEnabled(bool);
struct ProfilerGuiEnabled(bool);
pub struct ProfilerPlugin;
impl Plugin for ProfilerPlugin {
fn build(&self, app: &mut AppBuilder) {
<|fim_suffix|... | code_fim | hard | {
"lang": "rust",
"repo": "drhaynes/hands-on-rust",
"path": "/src/profiler_plugin.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Floxter/Bit-Country-Blockchain path: /pallets/primitives/src/lib.rs
// This file is part of Bit.Country.
// Copyright (C) 2020-2021 Bit.Country.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in comp... | code_fim | hard | {
"lang": "rust",
"repo": "Floxter/Bit-Country-Blockchain",
"path": "/pallets/primitives/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Index of a transaction in the chain.
pub type Index = u32;
/// A hash of some data used by the chain.
pub type Hash = sp_core::H256;
/// A timestamp: milliseconds since the unix epoch.
/// `u64` is enough to represent a duration of half a billion years, when the
/// time scale is milliseconds.
pub t... | code_fim | hard | {
"lang": "rust",
"repo": "Floxter/Bit-Country-Blockchain",
"path": "/pallets/primitives/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns all locked amount, `None` if calculation overflows.
pub fn total_amount(&self) -> Option<Balance> {
self.per_period.checked_mul(&self.period_count.into())
}
/// Returns locked amount for a given `time`.
///
/// Note this func assumes schedule is a valid one(non... | code_fim | hard | {
"lang": "rust",
"repo": "Floxter/Bit-Country-Blockchain",
"path": "/pallets/primitives/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let entries = parse_multilingual_wordnet_file(File::open(&path).unwrap());
let mut lexicon = Lexicon::new();
for entry in entries {
match entry {
Entry::Lemma(lemma) => {
let lexeme = Lexeme {
lemma: lemma.lemma,
pos... | code_fim | medium | {
"lang": "rust",
"repo": "dmerkus/Quenya",
"path": "/quenya/src/nld/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for entry in entries {
match entry {
Entry::Lemma(lemma) => {
let lexeme = Lexeme {
lemma: lemma.lemma,
pos: lemma.pos,
};
lexicon.add_lexeme(lexeme);
}
_ => {}
... | code_fim | hard | {
"lang": "rust",
"repo": "dmerkus/Quenya",
"path": "/quenya/src/nld/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmerkus/Quenya path: /quenya/src/nld/mod.rs
use crate::lexicon::{Lexicon, Lexeme};
use std::path::Path;
use wn::multi::parse::{parse_multilingual_wordnet_file, Entry, Lemma};
use std::fs::File;
<|fim_suffix|> let entries = parse_multilingual_wordnet_file(File::open(&path).unwrap());
let... | code_fim | medium | {
"lang": "rust",
"repo": "dmerkus/Quenya",
"path": "/quenya/src/nld/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FyroxEngine/Fyrox path: /editor/src/inspector/editors/spritesheet/window.rs
use crate::inspector::editors::spritesheet::SpriteSheetFramesPropertyEditorMessage;
use fyrox::{
animation::spritesheet::{SpriteSheetAnimation, SpriteSheetFramesContainer},
core::{algebra::Vector2, color::Color, ... | code_fim | hard | {
"lang": "rust",
"repo": "FyroxEngine/Fyrox",
"path": "/editor/src/inspector/editors/spritesheet/window.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ui.send_message(WidgetMessage::remove(self.grid, MessageDirection::ToWidget));
let (grid, cells) = make_grid(&mut ui.build_ctx(), self.animation.frames());
self.grid = grid;
self.cells = cells;
ui.send_message(WidgetMessage::link(
self.grid,
... | code_fim | hard | {
"lang": "rust",
"repo": "FyroxEngine/Fyrox",
"path": "/editor/src/inspector/editors/spritesheet/window.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> is_digit(c) || is_alpha(c)
}
fn is_whitespace(c: char) -> bool {
match c {
' ' | '\r' | '\t' | '\n' => true,
_ => false,
}
}
impl<'a> std::iter::Iterator for Scanner<'a> {
type Item = Result<Token, ScanError>;
fn next(&mut self) -> Option<Self::Item> {
let cu... | code_fim | hard | {
"lang": "rust",
"repo": "aptend/rlox",
"path": "/src/scanner.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aptend/rlox path: /src/scanner.rs
use std::fmt;
use std::str;
#[allow(non_camel_case_types)]
#[derive(Clone, Debug)]
pub enum TokenKind {
// Single-character tokens.
LEFT_PAREN,
RIGHT_PAREN,
LEFT_BRACE,
RIGHT_BRACE,
COMMA,
DOT,
MINUS,
PLUS,
SEMICOLON,
... | code_fim | hard | {
"lang": "rust",
"repo": "aptend/rlox",
"path": "/src/scanner.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn collect_identifier(&mut self) -> Result<TokenKind, ScanError> {
self.advance_while(&is_alphanumeric);
match self.current_lexeme.as_str() {
"and" => Ok(TokenKind::AND),
"class" => Ok(TokenKind::CLASS),
"else" => Ok(TokenKind::ELSE),
"fa... | code_fim | hard | {
"lang": "rust",
"repo": "aptend/rlox",
"path": "/src/scanner.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: whentze/aoc2020 path: /day1_1/src/main.rs
use std::{
error::Error,
io::{BufRead, stdin},
str::FromStr,
};
fn main() -> Result<(), Box<dyn Error>> {
let stdin = stdin();
let stdin = stdin.lock();
<|fim_suffix|> for line in stdin.lines() {
let num = usize::from_str... | code_fim | medium | {
"lang": "rust",
"repo": "whentze/aoc2020",
"path": "/day1_1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if hitmap[2020-num] {
println!("{}", num * (2020 - num));
return Ok(())
} else if num <= 2020 {
hitmap[num] = true;
}
}
Err("No pair of number sums to 2020".into())
}<|fim_prefix|>// repo: whentze/aoc2020 path: /day1_1/src/main.rs
use s... | code_fim | medium | {
"lang": "rust",
"repo": "whentze/aoc2020",
"path": "/day1_1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-chainblock/mitrid-core path: /tests/model/input.rs
use mitrid_core::base::Checkable;
use mitrid_core::base::Sizable;
use mitrid_core::base::Serializable;
use mitrid_core::util::Version;
use mitrid_core::base::Meta;
use mitrid_core::io::Storable;
use fixture::base::eval::*;
use fixture::bas... | code_fim | hard | {
"lang": "rust",
"repo": "rust-chainblock/mitrid-core",
"path": "/tests/model/input.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> count = Some(0);
let res = Input::store_list(&mut store, from.clone(), to.clone(), count.clone(), skip);
assert!(res.is_err());
from = None;
to = None;
count = None;
let res = Input::store_list(&mut store, from.clone(), to.clone(), count.clone(), skip);
assert!(res.is_ok... | code_fim | hard | {
"lang": "rust",
"repo": "rust-chainblock/mitrid-core",
"path": "/tests/model/input.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GKnirps/adventofcode-2019 path: /day-05/src/main.rs
use intcode::{parse, run_program, State};
use std::env;
use std::fs::File;
use std::io::{BufReader, Read};
use std::path::Path;
fn main() -> Result<(), String> {
let filename = env::args()
.nth(1)
.ok_or_else(|| "No file na... | code_fim | medium | {
"lang": "rust",
"repo": "GKnirps/adventofcode-2019",
"path": "/day-05/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MellowCobra/Fae-Interpreter path: /faerie/src/interpreter/ast.rs
use interpreter::token::Token;
use interpreter::data_type::Type;
pub trait Visit {
fn visit(&self) -> i32;
}
pub struct BinOp {
token: Token,
left: Box<Visit>,
op: Token,
right: Box<Visit>
}
<|fim_suffix|>im... | code_fim | hard | {
"lang": "rust",
"repo": "MellowCobra/Fae-Interpreter",
"path": "/faerie/src/interpreter/ast.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.op._type {
Type::ADD => self.left.visit() + self.right.visit(),
Type::SUB => self.left.visit() - self.right.visit(),
Type::MUL => self.left.visit() * self.right.visit(),
Type::DIV => self.left.visit() / self.right.visit(),
_ =>... | code_fim | hard | {
"lang": "rust",
"repo": "MellowCobra/Fae-Interpreter",
"path": "/faerie/src/interpreter/ast.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let event_loop = EventLoop::new();
let window = Window::new(&event_loop).unwrap();
let mut input = Input::new();
let mut counter = 0;
event_loop.run(move |event, _, control_flow| {
thread::sleep(Duration::new(1u64, 0u32));
input.update_inputs(&window, &ve... | code_fim | medium | {
"lang": "rust",
"repo": "shockham/volition",
"path": "/examples/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shockham/volition path: /examples/main.rs
use volition::Input;
use winit::{
event_loop::{ControlFlow, EventLoop},
window::Window,
};
use std::thread;
use std::time::Duration;
fn main() {
<|fim_suffix|> let mut counter = 0;
event_loop.run(move |event, _, control_flow| {
... | code_fim | medium | {
"lang": "rust",
"repo": "shockham/volition",
"path": "/examples/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sensudata/flux-lsp path: /src/shared/conversion.rs
use crate::protocol::properties::{
Diagnostic, Location, Position, Range,
};
use flux::ast::check;
use flux::ast::Package;
use flux::parser::parse_string;
use flux::semantic::walk::Node;
<|fim_suffix|>pub fn map_errors_to_diagnostics(
... | code_fim | hard | {
"lang": "rust",
"repo": "sensudata/flux-lsp",
"path": "/src/shared/conversion.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn create_file_node_from_text(
uri: String,
text: String,
) -> Package {
parse_string(uri.as_str(), text.as_str()).into()
}
pub fn flux_position_to_position(
pos: flux::ast::Position,
) -> Position {
Position {
line: pos.line - 1,
character: pos.column - 1,
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "sensudata/flux-lsp",
"path": "/src/shared/conversion.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lillanes/gridist path: /src/agent.rs
use grid::{Distance, Grid, Point, Tile};
use search::{astar, Path};
#[derive(Debug)]
pub struct Datum {
pub action: Point,
pub expansions: usize,
}
pub trait Agent {
fn act(&mut self,
grid: &mut Grid,
location: &Point,
... | code_fim | hard | {
"lang": "rust",
"repo": "lillanes/gridist",
"path": "/src/agent.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<H> RepeatedAstar<H>
where H: Fn(&Point, &Point) -> Distance
{
pub fn new(heuristic: H) -> RepeatedAstar<H> {
RepeatedAstar {
heuristic: heuristic,
path: None,
}
}
fn update_path(&mut self,
grid: &mut Grid,
... | code_fim | hard | {
"lang": "rust",
"repo": "lillanes/gridist",
"path": "/src/agent.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len == 7 && s == "keyence" {
ans = true;
}
'outer: for i in 0..(len + 1) {
for j in i + 1..(len + 1) {
let mut str: String = s[0..i].to_string();
str.push_str(&s[j..]);
if str == "keyence" {
ans = true;
brea... | code_fim | medium | {
"lang": "rust",
"repo": "mah-shee/keyence2019",
"path": "/src/bin/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mah-shee/keyence2019 path: /src/bin/b.rs
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
#[fastout]
fn main() {
<|fim_suffix|> if len == 7 && s == "keyence" {
ans = true;
}
'outer: for i in 0..(len + 1) {
for j in i + 1..(... | code_fim | medium | {
"lang": "rust",
"repo": "mah-shee/keyence2019",
"path": "/src/bin/b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chops76/AoC2018 path: /src/day24.rs
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::time::Instant;
use std::collections::HashMap;
use std::collections::HashSet;
use std::cmp;
use std::cmp::Ordering;
use std::collections::BinaryHeap;
#[derive(Debug)]
#[derive(PartialEq)]
#[derive(... | code_fim | hard | {
"lang": "rust",
"repo": "chops76/AoC2018",
"path": "/src/day24.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut tmp = order.clone();
//for unit in order.clone().into_sorted_vec() {
let mut u = tmp.pop();
while u != None {
let unit = u.unwrap();
//println!("{} {}", unit.num_units * unit.damage as i32, unit.initiative);
let mut best: Option<&Unit> = None;
let mut best_damage = 0;
for en... | code_fim | hard | {
"lang": "rust",
"repo": "chops76/AoC2018",
"path": "/src/day24.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> units
}
fn part1(units: &Vec<Unit>) -> usize {
let mut units = units.clone();
let mut units_left = HashMap::new();
for unit in &units {
units_left.insert(unit.id, unit.num_units as i32);
}
loop {
//println!("\n\n");
for i in 0..units.len() {
units.get_mut(i).unwrap().num_units = units_lef... | code_fim | hard | {
"lang": "rust",
"repo": "chops76/AoC2018",
"path": "/src/day24.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn merkle_tree_works() {
let a = sample_ro_tree();
// println!("{:?}", tree);
// println!("{:?}", tree.root());
assert_eq!(a.get_root().unwrap().unwrap(), sha256(H20));
assert!(a.check_data().is_ok());
assert!(a.check_tree().is_ok());
... | code_fim | hard | {
"lang": "rust",
"repo": "alexander-irbis/mt-rs",
"path": "/src/merkle_tree/generic.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.data.is_writeable() {
Ok(())
} else {
Err(Error::new_ro("Data storage is not writable"))
}
}
/// Clears all data
pub fn clear(&mut self) -> Result<()> {
self.data.clear()?;
self.tree.clear()
}
/// Appends a new d... | code_fim | hard | {
"lang": "rust",
"repo": "alexander-irbis/mt-rs",
"path": "/src/merkle_tree/generic.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexander-irbis/mt-rs path: /src/merkle_tree/generic.rs
b struct MerkleTree<D, T> where D: DataStorageReadonly, T: TreeStorage {
data: D,
tree: T,
}
impl <D, T> MerkleTree<D, T> where D: DataStorageReadonly, T: TreeStorage {
/// Creates an instance without checking of data integrity... | code_fim | hard | {
"lang": "rust",
"repo": "alexander-irbis/mt-rs",
"path": "/src/merkle_tree/generic.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: knpwrs/learning-rust path: /code/c05-03-structs-methods/src/main.rs
#[derive(Debug)]
struct Rectangle {
width: u32,
height: u32,
}
impl Rectangle {
// We still need to use the & before self, just as we did in &Rectangle. Methods can take
// ownership of self, borrow self immutab... | code_fim | medium | {
"lang": "rust",
"repo": "knpwrs/learning-rust",
"path": "/code/c05-03-structs-methods/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rect1 = Rectangle {
width: 100,
height: 120,
};
let rect2 = Rectangle {
width: 50,
height: 60,
};
let rect3 = Rectangle {
width: 300,
height: 400,
};
println!("area of rect1: {}", rect1.area());
println!("rect 1 can hold r... | code_fim | medium | {
"lang": "rust",
"repo": "knpwrs/learning-rust",
"path": "/code/c05-03-structs-methods/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> hs.iter()
.skip(1)
.fold(f, |acc, f| acc.intersection(f).cloned().collect())
.len()
})
.sum::<usize>()
.to_string()
}
}
#[derive(Debug)]
struct Group {
qs: Vec<String>,
}<|fim_prefix|>/... | code_fim | hard | {
"lang": "rust",
"repo": "hjaremko/advent-of-code",
"path": "/2020/src/days/day6.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hjaremko/advent-of-code path: /2020/src/days/day6.rs
use crate::utils::Day;
use aoc_fetch::AocInput;
use itertools::Itertools;
use std::collections::HashSet;
// use log::debug;
pub struct Day6 {
input: Vec<Group>,
}
impl Day for Day6 {
fn new(input: AocInput) -> Self {
Day6 {
... | code_fim | hard | {
"lang": "rust",
"repo": "hjaremko/advent-of-code",
"path": "/2020/src/days/day6.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_second_solution(&self) -> String {
self.input
.iter()
.map(|g| {
let hs: Vec<HashSet<char>> =
g.qs.iter()
.map(|x| x.chars().collect::<HashSet<char>>())
.collect();
... | code_fim | hard | {
"lang": "rust",
"repo": "hjaremko/advent-of-code",
"path": "/2020/src/days/day6.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>RigidBodyComponent {
pub handle: BodyHandle,
}<|fim_prefix|>// repo: risooonho/bytepath-rs path: /src/components/rigid_body.rs
use nphysics2d::object::BodyHandle;
use specs::{Component, VecStorage};
#[derive(Component, De<|fim_middle|>bug, Clone)]
#[storage(VecStorage)]
pub struct | code_fim | easy | {
"lang": "rust",
"repo": "risooonho/bytepath-rs",
"path": "/src/components/rigid_body.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: risooonho/bytepath-rs path: /src/components/rigid_body.rs
use nphysics2d::object::BodyHandle;
use specs::{Component, VecStorage};
#[derive(Component, De<|fim_suffix|>RigidBodyComponent {
pub handle: BodyHandle,
}<|fim_middle|>bug, Clone)]
#[storage(VecStorage)]
pub struct | code_fim | easy | {
"lang": "rust",
"repo": "risooonho/bytepath-rs",
"path": "/src/components/rigid_body.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gamma-delta/wgj_210 path: /src/simulator/test.rs
#![cfg(test)]
use std::str::FromStr;
use super::symbols::*;
#[test]
fn parse_parts_of_speech() {
let tests = [
(
"#####\n# #\n# # #\n# #\n#####",
PartOfSpeech::ParticleCollate,
),
... | code_fim | hard | {
"lang": "rust",
"repo": "gamma-delta/wgj_210",
"path": "/src/simulator/test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ##",
PartOfSpeech::Noun {
islands: 1,
depth: 0,
},
),
];
for (idx, (test, expect)) in tests.iter().enumerate() {
let res = Symbol::from_str(test).unwrap().part_of_speech;
assert_eq!(res, *expect, "testing idx... | code_fim | hard | {
"lang": "rust",
"repo": "gamma-delta/wgj_210",
"path": "/src/simulator/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zaki-yama/leetcode path: /dp/279.perfect-squares.rs
/*
* @lc app=leetcode id=279 lang=rust
*
* [279] Perfect Squares
*/
<|fim_suffix|>impl Solution {
pub fn num_squares(n: i32) -> i32 {
let mut ans = vec![std::i32::MAX - 1; (n + 1) as usize];
ans[0] = 0;
for i in... | code_fim | medium | {
"lang": "rust",
"repo": "zaki-yama/leetcode",
"path": "/dp/279.perfect-squares.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Solution {
pub fn num_squares(n: i32) -> i32 {
let mut ans = vec![std::i32::MAX - 1; (n + 1) as usize];
ans[0] = 0;
for i in 1..=n {
let mut j = 1;
while j * j <= i {
ans[i as usize] = cmp::min(ans[i as usize], ans[(i - j * j) as usi... | code_fim | medium | {
"lang": "rust",
"repo": "zaki-yama/leetcode",
"path": "/dp/279.perfect-squares.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tendermint/signatory path: /src/encoding/pkcs8.rs
//! Support for the **PKCS#8** private key format described in [RFC 5208]
//! and [RFC 5915].
//!
//! [RFC 5208]: https://tools.ietf.org/html/rfc5208
//! [RFC 5915]: https://tools.ietf.org/html/rfc5915
#[cfg(all(unix, feature = "std"))]
use supe... | code_fim | hard | {
"lang": "rust",
"repo": "tendermint/signatory",
"path": "/src/encoding/pkcs8.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Encode `self` and write it to a file at the given path, returning the
/// resulting `File` or a `Error`.
///
/// If the file does not exist, it will be created.
#[cfg(not(unix))]
fn generate_pkcs8_file<P: AsRef<Path>>(path: P) -> Result<File, Error> {
let path = path.as... | code_fim | hard | {
"lang": "rust",
"repo": "tendermint/signatory",
"path": "/src/encoding/pkcs8.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/generic-array/src/hex.rs
/
/
!
Generic
array
are
commonly
used
as
a
return
value
for
hash
digests
so
/
/
!
it
'
s
a
good
idea
to
allow
to
hexlify
them
easily
.
This
module
implements
/
/
!
std
:
:
fmt
:
:
LowerHex
and
std
:
:
fmt
:
:
UpperHex
t... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/generic-array/src/hex.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>
max_hex
]
.
chunks
(
1024
)
{
chunk
.
iter
(
)
.
enumerate
(
)
.
for_each
(
|
(
i
c
)
|
{
buf
[
i
*
2
]
=
LOWER_CHARS
[
(
c
>
>
4
)
as
usize
]
;
buf
[
i
*
2
+
1
]
=
LOWER_CHARS
[
(
c
&
0xF
)
as
usize
]
;
}
)
;
let
n
=
min
(
chunk
.
len
(
)
*
2
digits_left
)
;
f
.
write_str
(
unsafe
{
str
:
:
from_utf8_un... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/generic-array/src/hex.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.