text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>// Faster version, to check benchmarks.
// pub fn fibonacci(n: u32) -> u32 {
// if n == 0 || n == 1 {
// n
// } else {
// let mut previous = 1;
// let mut current = 1;
// for _ in 2..n {
// let new_current = previous + current;
// previous = ... | code_fim | medium | {
"lang": "rust",
"repo": "PacktPublishing/Rust-High-Performance",
"path": "/Chapter06/example3/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if image.height != 256 {
println!("The image height must be exactly 256 px");
}
self.imagebuf = image.data;
self.width = image.width;
self.height = image.height;
}
}<|fim_prefix|>// repo: resonancellc/spritecooker path: /src/spritesheet.rs
extern c... | code_fim | medium | {
"lang": "rust",
"repo": "resonancellc/spritecooker",
"path": "/src/spritesheet.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: resonancellc/spritecooker path: /src/spritesheet.rs
extern crate exoquant;
extern crate glob;
extern crate image;
extern crate stb_image;
use bitmap::Bitmap;
use stb_image::image::LoadResult;
use std::path::PathBuf;
#[derive(Default)]
pub struct Spritesheet {
pub width: usize,
pub heig... | code_fim | medium | {
"lang": "rust",
"repo": "resonancellc/spritecooker",
"path": "/src/spritesheet.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RCasatta/firma path: /lib/src/common/mod.rs
use crate::*;
use bitcoin::blockdata::opcodes;
use bitcoin::blockdata::script::Instruction::PushBytes;
use bitcoin::consensus::{deserialize, serialize};
use bitcoin::util::key;
use bitcoin::{Network, Script, Transaction};
use log::{LevelFilter, Metadat... | code_fim | hard | {
"lang": "rust",
"repo": "RCasatta/firma",
"path": "/lib/src/common/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let segwit_tx = "020000000001019c644affd9c62cef3a13c4d2facc4284bcce3f1769d4aeda062413ece120ffc80100000000ffffffff029b660900000000001600147a5d9c9672cb9c788c2b7f217a8b35af6e3f7e8bdee60300000000001976a914228e6b93d66a870fabb41dd064dedbd14804431388ac024730440220453ca5656c155e63bea0af0e83d59ea7097c3cc5b... | code_fim | hard | {
"lang": "rust",
"repo": "RCasatta/firma",
"path": "/lib/src/common/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_cached(&self, address: &str) -> anyhow::Result<String> {
let mut f = File::open(self.cache_fn(address)).expect("Unable to open file");
let mut data = String::new();
f.read_to_string(&mut data).expect("Reading failure");
let res = data.trim();
if res.l... | code_fim | hard | {
"lang": "rust",
"repo": "bbenligiray/api3-dao-tracker",
"path": "/server/src/ens.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bbenligiray/api3-dao-tracker path: /server/src/ens.rs
use hex_literal::hex;
use lazy_static::lazy_static;
use std::fs::File;
use std::io::Read;
use std::path::Path;
use tiny_keccak::{Hasher, Keccak};
use web3::contract::{Contract, Options};
use web3::types::{Address, H160, H256};
const ENS_REVE... | code_fim | hard | {
"lang": "rust",
"repo": "bbenligiray/api3-dao-tracker",
"path": "/server/src/ens.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut hasher = Keccak::v256();
hasher.update(node.as_slice());
hasher.finalize(&mut labelhash);
node = labelhash.to_vec();
}
node
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
pub fn namehash_works() {
assert_eq!(
namehash("eth... | code_fim | hard | {
"lang": "rust",
"repo": "bbenligiray/api3-dao-tracker",
"path": "/server/src/ens.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nzaharov/TravelingSalesman path: /src/cli.rs
use structopt::StructOpt;
#[derive(StructOpt)]
pub struct Cli {
#[structopt<|fim_suffix|>t(short = "P", long, default_value = "5000")]
pub population: usize,
#[structopt(short = "G", long, default_value = "1000")]
pub generations: usi... | code_fim | medium | {
"lang": "rust",
"repo": "nzaharov/TravelingSalesman",
"path": "/src/cli.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>t(short = "P", long, default_value = "5000")]
pub population: usize,
#[structopt(short = "G", long, default_value = "1000")]
pub generations: usize,
}<|fim_prefix|>// repo: nzaharov/TravelingSalesman path: /src/cli.rs
use structopt::StructOpt;
#[derive(StructOpt)]
pub struct Cli {
#[stru... | code_fim | medium | {
"lang": "rust",
"repo": "nzaharov/TravelingSalesman",
"path": "/src/cli.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Hash)]
pub struct AnswerId(pub String);<|fim_prefix|>// repo: elitecodegroovy/thinking-in-rust path: /app04/src/types/answer.rs
use serde::{Deserialize, Serialize};
use crate::types::question::QuestionId;
<|fim_middle|>#[derive(Serialize, De... | code_fim | medium | {
"lang": "rust",
"repo": "elitecodegroovy/thinking-in-rust",
"path": "/app04/src/types/answer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elitecodegroovy/thinking-in-rust path: /app04/src/types/answer.rs
use serde::{Deserialize, Serialize};
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Answer {
pub id: AnswerId,
pub content: String,
pub question_id: QuestionId,
}
#[derive(Deserialize, Seria... | code_fim | easy | {
"lang": "rust",
"repo": "elitecodegroovy/thinking-in-rust",
"path": "/app04/src/types/answer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use toml;
let table = {
let config_str = include_str!("../../../configs/thrift_calc.toml");
toml::from_str(config_str).expect("Failed to load configs/thrift_calc.toml")
};
let config = load_config(&table).unwrap();
assert_eq!(config.protocol.name(), "thrift");
as... | code_fim | hard | {
"lang": "rust",
"repo": "jacktuck/rpc-perf",
"path": "/src/codec/thrift/config.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jacktuck/rpc-perf path: /src/codec/thrift/config.rs
// rpc-perf - RPC Performance Testing
// Copyright 2015 Twitter, Inc
//
// 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 ... | code_fim | hard | {
"lang": "rust",
"repo": "jacktuck/rpc-perf",
"path": "/src/codec/thrift/config.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ProtocolParseFactory for ThriftParseFactory {
fn new(&self) -> Box<ProtocolParse> {
Box::new(ThriftParse)
}
fn name(&self) -> &str {
"thrift"
}
}
impl ProtocolParse for ThriftParse {
fn parse(&self, bytes: &[u8]) -> ParsedResponse {
parse::parse_response(... | code_fim | hard | {
"lang": "rust",
"repo": "jacktuck/rpc-perf",
"path": "/src/codec/thrift/config.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn negate_imm(y: &isize) -> isize {
negate(y)
}
pub fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs
// run-pass
#![allow(dead_code)]
// pretty-expanded FIXME #23616
fn negate(x: &isize) -> isize {
<|fim_middle|> -*... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs
// run-pass
#![allow(dead_code)]
// pretty-expanded FIXME #23616
fn negate(x: &isize) -> isize {
-*x
}
fn negate_mut(y: &mut isize) -> isize {
<|fim_suffix|> negate(y)
}
pub fn main() {}<|fim... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> negate(y)
}
fn negate_imm(y: &isize) -> isize {
negate(y)
}
pub fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs
// run-pass
#![allow(dead_code)]
// pretty-expanded FIXME #23616
fn negate(x: &isize) -> isize {
... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !nums.is_empty() && cur.len() < 3 {
let i = nums
.iter()
.position(|&x| x != nums[0])
.unwrap_or(nums.len());
let sliced = &nums[0.max(i as isize + cur.len() as isize - 4) as usize..];
cur.push(sliced[0]);
... | code_fim | hard | {
"lang": "rust",
"repo": "seandewar/challenge-solutions",
"path": "/leetcode/medium/4sum.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seandewar/challenge-solutions path: /leetcode/medium/4sum.rs
// https://leetcode.com/problems/4sum
//
// Complexity: runtime O((n^3)*logn), space O(logn) [from sort_unstable()].
impl Solution {
pub fn four_sum(mut nums: Vec<i32>, target: i32) -> Vec<Vec<i32>> {
let mut res = vec![];... | code_fim | hard | {
"lang": "rust",
"repo": "seandewar/challenge-solutions",
"path": "/leetcode/medium/4sum.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// easy and fast implementation
pub fn same_necklaces(mut s1: String, s2: String) -> bool {
if s1.len() != s2.len() {
return false;
}
let s3 = s1.clone();
s1.push_str(&s3[..]);
return s1.contains(&s2[..]);
}<|fim_prefix|>// repo: Tiv0w/ruster-tester-tinker path: /src/daily_pr... | code_fim | hard | {
"lang": "rust",
"repo": "Tiv0w/ruster-tester-tinker",
"path": "/src/daily_programmer/dp_383.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in 1..elements_len {
if self.elements == other_necklace {
return true;
}
self.rotate_one();
}
false
}
}
//
pub fn same_necklace() {
let mut necklace = Necklace::new(String::from("salut"));
println!("Same? {}", ... | code_fim | medium | {
"lang": "rust",
"repo": "Tiv0w/ruster-tester-tinker",
"path": "/src/daily_programmer/dp_383.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tiv0w/ruster-tester-tinker path: /src/daily_programmer/dp_383.rs
// useless but cool to learn structs
struct Necklace {
elements: String,
}
impl Necklace {
fn new(elements: String) -> Necklace {
Necklace { elements }
}
fn rotate_one(&mut self) {
<|fim_suffix|>// easy an... | code_fim | hard | {
"lang": "rust",
"repo": "Tiv0w/ruster-tester-tinker",
"path": "/src/daily_programmer/dp_383.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Zeroize for VaultSync {
fn zeroize(&mut self) {}
}
impl VaultSync {
/// Create and start a new Vault using Worker.
pub fn create_with_worker(ctx: &Context, vault: &Address) -> Result<Self> {
let address: Address = random();
debug!("Starting VaultSync at {}", &address);
... | code_fim | hard | {
"lang": "rust",
"repo": "ecafkoob/ockam",
"path": "/implementations/rust/ockam/ockam_vault_sync_core/src/vault_sync.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ecafkoob/ockam path: /implementations/rust/ockam/ockam_vault_sync_core/src/vault_sync.rs
use crate::{Vault, VaultRequestMessage, VaultResponseMessage, VaultTrait};
#[cfg(not(feature = "std"))]
use ockam_core::compat::rand::random;
use ockam_core::{Address, Result, ResultMessage, Route};
use ocka... | code_fim | hard | {
"lang": "rust",
"repo": "ecafkoob/ockam",
"path": "/implementations/rust/ockam/ockam_vault_sync_core/src/vault_sync.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DoumanAsh/actix-http path: /src/client/error.rs
use std::io;
use derive_more::{Display, From};
use trust_dns_resolver::error::ResolveError;
#[cfg(feature = "ssl")]
use openssl::ssl::{Error as SslError, HandshakeError};
use crate::error::{Error, ParseError, ResponseError};
use crate::response:... | code_fim | hard | {
"lang": "rust",
"repo": "DoumanAsh/actix-http",
"path": "/src/client/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Connection io error
#[display(fmt = "{}", _0)]
Io(io::Error),
}
#[derive(Debug, Display)]
pub enum InvalidUrlKind {
#[display(fmt = "Missing url scheme")]
MissingScheme,
#[display(fmt = "Unknown url scheme")]
UnknownScheme,
#[display(fmt = "Missing host name")]
Mis... | code_fim | hard | {
"lang": "rust",
"repo": "DoumanAsh/actix-http",
"path": "/src/client/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MichaelSquires/synacor-challenge path: /src/utils.rs
extern crate anyhow;
extern crate fern;
use anyhow::Result;
#[allow(unused_imports)]
use log::{debug, error, info, trace, warn};
pub fn setup_logger(level: log::LevelFilter) -> Result<()> {
let colors = fern::colors::ColoredLevelConfig::... | code_fim | hard | {
"lang": "rust",
"repo": "MichaelSquires/synacor-challenge",
"path": "/src/utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Setup the logger
setup_logger(match matches.occurrences_of("verbose") {
0 => log::LevelFilter::Warn,
1 => log::LevelFilter::Info,
2 => log::LevelFilter::Debug,
_ => log::LevelFilter::Trace,
})?;
Ok(matches)
}<|fim_prefix|>// repo: MichaelSquires/synacor-... | code_fim | hard | {
"lang": "rust",
"repo": "MichaelSquires/synacor-challenge",
"path": "/src/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Create the parser and parse the command line
let matches = clap::App::new(&argv[0]).args(&options).get_matches();
// Setup the logger
setup_logger(match matches.occurrences_of("verbose") {
0 => log::LevelFilter::Warn,
1 => log::LevelFilter::Info,
2 => log::Level... | code_fim | hard | {
"lang": "rust",
"repo": "MichaelSquires/synacor-challenge",
"path": "/src/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: atsamd-rs/atsamd path: /pac/atsame51n/src/sercom0/usart_ext/ctrlc.rs
#[doc = "Register `CTRLC` reader"]
pub struct R(crate::R<CTRLC_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<CTRLC_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
i... | code_fim | hard | {
"lang": "rust",
"repo": "atsamd-rs/atsamd",
"path": "/pac/atsame51n/src/sercom0/usart_ext/ctrlc.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `DATA32B` writer - Data 32 Bit"]
pub struct DATA32B_W<'a> {
w: &'a mut W,
}
impl<'a> DATA32B_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: DATA32B_A) -> &'a mut W {
self.bits(variant.into())
... | code_fim | hard | {
"lang": "rust",
"repo": "atsamd-rs/atsamd",
"path": "/pac/atsame51n/src/sercom0/usart_ext/ctrlc.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Display for City {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
let lat_c = if self.lat >= 0.0 { 'N' } else { 'S' };
let lon_c = if self.lon >= 0.0 { 'E' } else { 'W' };
write!(f, "{}: {:.3}°{} {:.3}°{}",
self.name, self.lat.abs(), lat_c, self.lon.abs(... | code_fim | hard | {
"lang": "rust",
"repo": "pathbox/learning-rust",
"path": "/rust-by-example/print/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pathbox/learning-rust path: /rust-by-example/print/src/main.rs
use std::fmt::{self, Formatter, Display};
#[derive(Debug)]
struct MinMax(i64, i64);
// Implement `Display` for `MinMax`
impl fmt::Display for MinMax {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// use self.n... | code_fim | hard | {
"lang": "rust",
"repo": "pathbox/learning-rust",
"path": "/rust-by-example/print/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wmanley/rustysd path: /src/control/control.rs
use crate::units::*;
use serde_json::Value;
#[derive(Debug)]
pub enum Command {
ListUnits(Option<UnitSpecialized>),
Status(Option<String>),
Restart(String),
}
enum ParseError {
MethodNotFound(String),
ParamsInvalid(String),
}
f... | code_fim | hard | {
"lang": "rust",
"repo": "wmanley/rustysd",
"path": "/src/control/control.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn format_service(srvc_unit: &Unit) -> Value {
let mut map = serde_json::Map::new();
map.insert("Name".into(), Value::String(srvc_unit.conf.name()));
if let UnitSpecialized::Service(srvc) = &srvc_unit.specialized {
map.insert(
"Sockets".into(),
Value::Array(... | code_fim | hard | {
"lang": "rust",
"repo": "wmanley/rustysd",
"path": "/src/control/control.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: d0cd/crisper path: /src/lib.rs
pub mod proto {
pub mod reqresp {
include!(concat!(env!("OUT_DIR"), "/crisper.proto.reqresp.rs"));
}
pub mod lattice {
include!(concat!(env!("OUT_DIR"<|fim_suffix|>!("OUT_DIR"), "/crisper.proto.shared.rs"));
}
}
pub mod lattice;
pub... | code_fim | medium | {
"lang": "rust",
"repo": "d0cd/crisper",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>!("OUT_DIR"), "/crisper.proto.shared.rs"));
}
}
pub mod lattice;
pub mod socketcache;<|fim_prefix|>// repo: d0cd/crisper path: /src/lib.rs
pub mod proto {
pub mod reqresp {
include!(concat!(env!("OUT_DIR"), "/crisper.proto.reqresp.rs"));
}
pub mod lattice {
include!(conca... | code_fim | medium | {
"lang": "rust",
"repo": "d0cd/crisper",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (texture_id, pass_data) in &self.passes {
if let Some(texture) = context.get_texture(*texture_id) {
frame
.draw(
&pass_data.vertex_buffer,
&pass_data.index_buffer,
&context.p... | code_fim | hard | {
"lang": "rust",
"repo": "Cierpliwy/sdf-test",
"path": "/src/ui/label.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_style(&self) -> UILabelStyle {
self.style
}
pub fn set_style(&mut self, style: UILabelStyle) {
self.style = style;
}
pub fn get_bounding_box(&self, style: UILabelStyle) -> Rect<f32> {
let bb = self.bounding_box;
let size = style.size;
... | code_fim | hard | {
"lang": "rust",
"repo": "Cierpliwy/sdf-test",
"path": "/src/ui/label.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cierpliwy/sdf-test path: /src/ui/label.rs
use crate::ui::widget::{UILayout, UISize, UIWidget};
use glium::backend::{Context, Facade};
use glium::draw_parameters::DrawParameters;
use glium::index::PrimitiveType;
use glium::texture::{ClientFormat, MipmapsOption, RawImage2d, Texture2d, TextureCreat... | code_fim | hard | {
"lang": "rust",
"repo": "Cierpliwy/sdf-test",
"path": "/src/ui/label.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // let bodyj = req.get::<bodyparser::Json>();
// match bodyj.unwrap() {
// Some(b) => println!("{}", b),
// _ => println!("nah")
// }
// println!("logging in");
// match body {
// Ok(Some(packet)) => authenticate(packet.auth.id),
// _ => Err(IronError::... | code_fim | medium | {
"lang": "rust",
"repo": "altschuler/hans",
"path": "/src/routes/auth.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // match bodyj.unwrap() {
// Some(b) => println!("{}", b),
// _ => println!("nah")
// }
// println!("logging in");
// match body {
// Ok(Some(packet)) => authenticate(packet.auth.id),
// _ => Err(IronError::new(StringError("parsing failed".to_string()), stat... | code_fim | medium | {
"lang": "rust",
"repo": "altschuler/hans",
"path": "/src/routes/auth.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: altschuler/hans path: /src/routes/auth.rs
extern crate iron;
extern crate bodyparser;
use iron::prelude::*;
use iron::status;
use core::data::*;
use core::error::*;
<|fim_suffix|> // let bodyj = req.get::<bodyparser::Json>();
// match bodyj.unwrap() {
// Some(b) => println!("{... | code_fim | medium | {
"lang": "rust",
"repo": "altschuler/hans",
"path": "/src/routes/auth.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: edwinmarinn/abstreet path: /sim/src/make/scenario.rs
use crate::{
DrivingGoal, ParkingSpot, PersonID, SidewalkSpot, Sim, TripSpec, VehicleSpec, VehicleType,
BIKE_LENGTH, MAX_CAR_LENGTH, MIN_CAR_LENGTH,
};
use abstutil::Timer;
use geom::{Distance, Duration, Speed, Time};
use map_model::{B... | code_fim | hard | {
"lang": "rust",
"repo": "edwinmarinn/abstreet",
"path": "/sim/src/make/scenario.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn seed_parked_cars(
parked_cars_per_bldg: Vec<(BuildingID, usize)>,
total_parked_cars: usize,
sim: &mut Sim,
map: &Map,
base_rng: &mut XorShiftRng,
timer: &mut Timer,
) {
// We always need the same number of cars
let mut rand_cars: Vec<VehicleSpec> = std::iter::repeat_with... | code_fim | hard | {
"lang": "rust",
"repo": "edwinmarinn/abstreet",
"path": "/sim/src/make/scenario.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn repeat_days(mut self, days: usize) -> Scenario {
self.scenario_name = format!("{} repeated for {} days", self.scenario_name, days);
for person in &mut self.people {
let mut trips = Vec::new();
let mut offset = Duration::ZERO;
for _ in 0..days ... | code_fim | hard | {
"lang": "rust",
"repo": "edwinmarinn/abstreet",
"path": "/sim/src/make/scenario.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qiongtubao/rust-redis path: /libs/mio_server/src/object/single_list.rs
struct Node<T> {
value: T,
next: Option<Box<Node<T>>>,
}
impl<T> Node<T> {
fn new(elem: T) -> Self {
Node {
value: elem,
next: None,
}
}
fn set_next(&mut self, nod... | code_fim | medium | {
"lang": "rust",
"repo": "qiongtubao/rust-redis",
"path": "/libs/mio_server/src/object/single_list.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(ref mut x) = self.next {
return x.get_last();
}
self
}
fn push(&mut self, elem: T) {
let new_node = Node::new(elem);
self.get_last().set_next(new_node);
}
}
#[derive(Clone, Debug)]
struct List<T> {
len: usize,
next: Opti... | code_fim | medium | {
"lang": "rust",
"repo": "qiongtubao/rust-redis",
"path": "/libs/mio_server/src/object/single_list.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// `.proto` data for this file.
pub fn proto(&self) -> &FileDescriptorProto {
match &self.imp {
FileDescriptorImpl::Generated(g) => &g.proto,
FileDescriptorImpl::Dynamic(d) => &d.proto,
}
}
/// Direct dependencies of this file.
pub fn deps(&sel... | code_fim | hard | {
"lang": "rust",
"repo": "Tim-Zhang/rust-protobuf",
"path": "/protobuf/src/reflect/file/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tim-Zhang/rust-protobuf path: /protobuf/src/reflect/file/mod.rs
use std::collections::HashSet;
use std::hash::Hash;
use std::hash::Hasher;
use std::sync::Arc;
use crate::descriptor::DescriptorProto;
use crate::descriptor::FileDescriptorProto;
use crate::reflect::file::dynamic::DynamicFileDescri... | code_fim | hard | {
"lang": "rust",
"repo": "Tim-Zhang/rust-protobuf",
"path": "/protobuf/src/reflect/file/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
FileDescriptorImpl::Generated(g) => {
Hash::hash(&(*g as *const GeneratedFileDescriptor), state)
}
FileDescriptorImpl::Dynamic(a) => {
Hash::hash(&(&**a as *const DynamicFileDescriptor), state)
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "Tim-Zhang/rust-protobuf",
"path": "/protobuf/src/reflect/file/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spacemeshos/tytle path: /tytle_core/src/ast/semantic/ast_walker.rs
use crate::ast::expression::*;
use crate::ast::semantic::AstWalkError;
use crate::ast::statement::*;
use crate::ast::Ast;
pub type AstWalkResult = Result<(), AstWalkError>;
pub trait AstWalker {
fn walk_ast(&mut self, ast: ... | code_fim | hard | {
"lang": "rust",
"repo": "spacemeshos/tytle",
"path": "/tytle_core/src/ast/semantic/ast_walker.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn walk_expr(&mut self, ctx_proc: &str, expr: &mut Expression) -> AstWalkResult {
match expr.expr_ast {
ExpressionAst::Literal(_) => self.on_literal_expr(ctx_proc, expr),
ExpressionAst::ProcCall(ref call_name, ref mut call_params, ref mut _call_proc_id) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "spacemeshos/tytle",
"path": "/tytle_core/src/ast/semantic/ast_walker.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // block
fn on_block_stmt_start(
&mut self,
_ctx_proc: &str,
_block_stmt: &mut BlockStatement,
) -> AstWalkResult {
Ok(())
}
fn on_block_stmt_end(
&mut self,
_ctx_proc: &str,
_block_stmt: &mut BlockStatement,
) -> AstWalkResu... | code_fim | hard | {
"lang": "rust",
"repo": "spacemeshos/tytle",
"path": "/tytle_core/src/ast/semantic/ast_walker.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: russelltg/srt-rs path: /srt-tokio/tests/simple.rs
use std::time::{Duration, Instant};
use anyhow::Error;
use bytes::Bytes;
use futures::prelude::*;
use srt_tokio::{SocketStatistics, SrtSocket};
use tokio::time::sleep;
#[tokio::test]
async fn test() {
let _ = pretty_env_logger::try_init();
... | code_fim | medium | {
"lang": "rust",
"repo": "russelltg/srt-rs",
"path": "/srt-tokio/tests/simple.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(rx.statistics().next().await, Some(SocketStatistics::new()));
assert_eq!(rx.try_next().await?.map(|(_i, b)| b), Some(b"1"[..].into()));
assert_eq!(rx.try_next().await?.map(|(_i, b)| b), Some(b"2"[..].into()));
assert_eq!(rx.try_next().await?.map(|(_i, b)| b), So... | code_fim | hard | {
"lang": "rust",
"repo": "russelltg/srt-rs",
"path": "/srt-tokio/tests/simple.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> (c, name)
})
// Write everything into the new file
.for_each(|(c, name)| writeln!(out_file, "{}\t{}", c, name).unwrap());
Ok(())
}<|fim_prefix|>// repo: barionleg/my-albert-extensions_austereich path: /uni/prepare-data.rs
use std::{
error::Error,
fs,
... | code_fim | hard | {
"lang": "rust",
"repo": "barionleg/my-albert-extensions_austereich",
"path": "/uni/prepare-data.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Convert the name into lowercase. Will make searching faster.
let name = it.next().unwrap();
let name = name.to_ascii_lowercase();
// Make sure our parsing assumptions are correct
assert!(it.next().is_none());
assert!(name.is_ascii... | code_fim | hard | {
"lang": "rust",
"repo": "barionleg/my-albert-extensions_austereich",
"path": "/uni/prepare-data.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: barionleg/my-albert-extensions_austereich path: /uni/prepare-data.rs
use std::{
error::Error,
fs,
io::Write,
};
fn main() -> Result<(), Box<dyn Error>> {
let contents = fs::read_to_string("NamesList.txt")?;
let mut out_file = fs::File::create("symbols.txt").unwrap();
<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "barionleg/my-albert-extensions_austereich",
"path": "/uni/prepare-data.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cnheider/pathtracer path: /common/src/lib.rs
#![no_std]
#![feature(core_intrinsics)]
#![allow(dead_code)]
<|fim_suffix|>pub use color::{Color, BLACK, WHITE};
pub use grid::{GridDevice, IndexRange};
pub use material::Material;
pub use object::{BoundingBox, Object};
pub use polygon::Polygon;
pub ... | code_fim | medium | {
"lang": "rust",
"repo": "cnheider/pathtracer",
"path": "/common/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use color::{Color, BLACK, WHITE};
pub use grid::{GridDevice, IndexRange};
pub use material::Material;
pub use object::{BoundingBox, Object};
pub use polygon::Polygon;
pub use scratch::ScratchSpace;
pub use vector::Ray;
pub use vector::Vector3;<|fim_prefix|>// repo: cnheider/pathtracer path: /common/s... | code_fim | medium | {
"lang": "rust",
"repo": "cnheider/pathtracer",
"path": "/common/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dwlehman/peripety path: /src/peripety/src/lib.rs
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate regex;
extern crate libc;
<|fim_suffix|>mod error;
mod event;
mod blk_info;
mod dm;
mod scsi;
mod sysfs;<|fim_middle|>pub use self::error::PeripetyE... | code_fim | medium | {
"lang": "rust",
"repo": "dwlehman/peripety",
"path": "/src/peripety/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod error;
mod event;
mod blk_info;
mod dm;
mod scsi;
mod sysfs;<|fim_prefix|>// repo: dwlehman/peripety path: /src/peripety/src/lib.rs
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate regex;
extern crate libc;
<|fim_middle|>pub use self::error::PeripetyE... | code_fim | medium | {
"lang": "rust",
"repo": "dwlehman/peripety",
"path": "/src/peripety/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/object/src/lib.rs
#![deny(missing_docs)]
#![deny(missing_debug_implementations)]
#![no_std]
#![allow(clippy::collapsible_if)]
#![allow(clippy::comparison_chain)]
#![allow(clippy::mat... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/object/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod common;
pub use common::*;
#[macro_use]
pub mod endian;
pub use endian::*;
#[macro_use]
pub mod pod;
pub use pod::*;
#[cfg(feature = "read_core")]
pub mod read;
#[cfg(feature = "read_core")]
pub use read::*;
#[cfg(feature = "write_core")]
pub mod write;
#[cfg(feature = "archive")]
pub mod archive... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/object/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> match *self {
Error::HttpError(ref msg) => write!(fmt, "{}", msg),
Error::IoError(ref msg) => write!(fmt, "{}", msg),
}
}
}<|fim_prefix|>// repo: nathanjent/nathanjent path: /http_router/src/errors.rs
use http::Error as HttpError;
use std::error::Error as StdEr... | code_fim | medium | {
"lang": "rust",
"repo": "nathanjent/nathanjent",
"path": "/http_router/src/errors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match *self {
Error::HttpError(_) => "http error",
Error::IoError(_) => "io error",
}
}
fn cause(&self) -> Option<&StdError> {
match *self {
_ => None,
}
}
}
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::For... | code_fim | medium | {
"lang": "rust",
"repo": "nathanjent/nathanjent",
"path": "/http_router/src/errors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nathanjent/nathanjent path: /http_router/src/errors.rs
use http::Error as HttpError;
use std::error::Error as StdError;
use std::io::Error as IoError;
use std::fmt;
#[derive(Debug)]
pub enum Error {
HttpError(HttpError),
IoError(IoError),
}
impl From<HttpError> for Error {
fn from... | code_fim | medium | {
"lang": "rust",
"repo": "nathanjent/nathanjent",
"path": "/http_router/src/errors.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KentarouSuzuki/simple-server path: /by-rocket/src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate rocket;
extern crate serde;
extern crate rocket_contrib;
extern crate server_info;
<|fim_suffix|> rocket::ignite().mount("/", routes![route::root]).launch();
}<|fi... | code_fim | easy | {
"lang": "rust",
"repo": "KentarouSuzuki/simple-server",
"path": "/by-rocket/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> rocket::ignite().mount("/", routes![route::root]).launch();
}<|fim_prefix|>// repo: KentarouSuzuki/simple-server path: /by-rocket/src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]
<|fim_middle|>#[macro_use] extern crate rocket;
extern crate serde;
extern crate rocket_contrib;
extern crate serv... | code_fim | medium | {
"lang": "rust",
"repo": "KentarouSuzuki/simple-server",
"path": "/by-rocket/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: geomatsi/rust-blue-pill-tests path: /src/bin/adc-dma-test2.rs
#![no_main]
#![no_std]
use cm::singleton;
use cortex_m as cm;
use cortex_m_rt::entry;
use cortex_m_semihosting::hprintln;
use hal::adc;
use hal::gpio;
use hal::pac;
use hal::prelude::*;
use panic_semihosting as _;
use stm32f1xx_hal a... | code_fim | hard | {
"lang": "rust",
"repo": "geomatsi/rust-blue-pill-tests",
"path": "/src/bin/adc-dma-test2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Configure pa0 as an analog input
let adc_ch0 = gpioa.pa0.into_analog(&mut gpioa.crl);
let mut adc_dma = adc1.with_dma(adc_ch0, dma_ch1);
let mut buf = singleton!(: [u16; 8] = [0; 8]).unwrap();
unsafe {
G_ADC.replace(adc_dma);
G_BUF.replace(buf);
}
loop {
... | code_fim | medium | {
"lang": "rust",
"repo": "geomatsi/rust-blue-pill-tests",
"path": "/src/bin/adc-dma-test2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> hback.push(vs[3 * n - i - 1]);
let w = hback.pop().unwrap();
sback += vs[3 * n - i - 1] - w;
ssback.push(sback);
}
println!(
"{}",
ssfront
.iter()
.zip(ssback.iter().rev())
.map(|(f, b)| f - b)
.max()
... | code_fim | hard | {
"lang": "rust",
"repo": "MiyamonY/atcoder",
"path": "/abc/062/d/02/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MiyamonY/atcoder path: /abc/062/d/02/src/main.rs
use std::collections::BinaryHeap;
#[allow(unused_macros)]
macro_rules! scan {
() => {
{
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().to_string()
... | code_fim | hard | {
"lang": "rust",
"repo": "MiyamonY/atcoder",
"path": "/abc/062/d/02/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
pub(crate) fn test_blank_floor_generation() {
let blank_floor = FloorBuilder::<Blank>::blank(
FloorId(0),
10.try_into().unwrap(),
10.try_into().unwrap(),
false,
);
assert!(blank_floor.height.as_unbounded() == 10);
... | code_fim | hard | {
"lang": "rust",
"repo": "benluelo/game",
"path": "/dungeon/src/floor_builder/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: benluelo/game path: /dungeon/src/floor_builder/mod.rs
#[allow(clippy::wildcard_imports)]
use crate::{
dungeon_tile::DungeonTile,
floor_builder::{floor_builder_state::*, to_block_character::ToAsciiCharacter},
point_index::PointIndex,
Column, FloorId, Point, Row,
};
use bounded_int... | code_fim | hard | {
"lang": "rust",
"repo": "benluelo/game",
"path": "/dungeon/src/floor_builder/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut counter = 0;
for i_y in start_y.range_to_inclusive(end_y) {
for i_x in start_x.range_to_inclusive(end_x) {
if !(i_x == point.row.get() && i_y == point.column.get())
&& self.is_wall(Point {
row: Row::new(i_x),
... | code_fim | hard | {
"lang": "rust",
"repo": "benluelo/game",
"path": "/dungeon/src/floor_builder/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: florian1345/concurrent-event path: /src/lib.rs
//! This crate implements an event which executes registered event handlers
//! concurrently. Additionally, each handler is assigned an ID with which it
//! can be referenced after creation. This allows for associated state for each
//! event handle... | code_fim | hard | {
"lang": "rust",
"repo": "florian1345/concurrent-event",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<A: Copy + Send, H: EventHandler<A>> Event<A, H> {
/// Creates a new event without handlers.
pub fn new() -> Event<A, H> {
Event {
arg_type: PhantomData,
handlers: HashMap::new()
}
}
/// Emits an event, invoking all currently registered handler... | code_fim | hard | {
"lang": "rust",
"repo": "florian1345/concurrent-event",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 610968110/rust- path: /src/rust_01_input.rs
use std::io;
//接收键盘输入
pub fn run() {
println!("Guess the number");
println!("Please input your guess:");
//::是调用String的关联函数new,相当于new是String的静态函数
let mut guess =<|fim_suffix|>ut guess)
.expect("Filed to read line!");
printl... | code_fim | medium | {
"lang": "rust",
"repo": "610968110/rust-",
"path": "/src/rust_01_input.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> String::new();
//如果没有第一行的use引用,也可以写std::io::stdin().xxx
io::stdin().read_line(&mut guess)
.expect("Filed to read line!");
println!("your guess {}", guess);
}<|fim_prefix|>// repo: 610968110/rust- path: /src/rust_01_input.rs
use std::io;
//接收键盘输入
pub fn run() {
println!("Guess th... | code_fim | medium | {
"lang": "rust",
"repo": "610968110/rust-",
"path": "/src/rust_01_input.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nickray/lpc55s6x-usbd path: /src/lib.rs
//! USB peripheral driver for NXP LPC55S6x microcontrollers.
//!
//! Derivative of the `stm32-usbd<|fim_suffix|>s for several STM32 microcontrollers.
#![no_std]<|fim_middle|>` crate, which merged previous
//! implementation | code_fim | easy | {
"lang": "rust",
"repo": "nickray/lpc55s6x-usbd",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>` crate, which merged previous
//! implementations for several STM32 microcontrollers.
#![no_std]<|fim_prefix|>// repo: nickray/lpc55s6x-usbd path: /src/lib.rs
//! USB peripheral driver for NXP LPC55S6x microc<|fim_middle|>ontrollers.
//!
//! Derivative of the `stm32-usbd | code_fim | easy | {
"lang": "rust",
"repo": "nickray/lpc55s6x-usbd",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>s for several STM32 microcontrollers.
#![no_std]<|fim_prefix|>// repo: nickray/lpc55s6x-usbd path: /src/lib.rs
//! USB peripheral driver for NXP LPC55S6x microcontrollers.
//!
//! Derivative of the `stm32-usbd<|fim_middle|>` crate, which merged previous
//! implementation | code_fim | easy | {
"lang": "rust",
"repo": "nickray/lpc55s6x-usbd",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> string.chars().filter(|x| x.is_numeric())
.map(|x| x.to_string().parse::<i32>().unwrap())
//.sum()
.fold(0, |sum, i| sum+i)
}
fn main() {
let s = getline();
println!("{}", extract_int_sum(s.trim()));
}<|fim_prefix|>// repo: mottodora/contest path: /yukicoder/289.rs
fn... | code_fim | easy | {
"lang": "rust",
"repo": "mottodora/contest",
"path": "/yukicoder/289.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mottodora/contest path: /yukicoder/289.rs
fn getline() -> String{
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok();
return ret;
}
<|fim_suffix|> string.chars().filter(|x| x.is_numeric())
.map(|x| x.to_string().parse::<i32>().unwrap())
//.sum(... | code_fim | easy | {
"lang": "rust",
"repo": "mottodora/contest",
"path": "/yukicoder/289.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TAI-REx/black-hat-rust path: /ch_10/client/src/main.rs
use clap::{App, SubCommand};
mod api;
mod cli;
mod config;
mod error;
use config::Config;
pub use error::Error;
fn main() -> Result<(), anyhow::Error> {
<|fim_suffix|> if let Some(_) = cli.subcommand_matches(cli::TOKEN) {
cli::... | code_fim | hard | {
"lang": "rust",
"repo": "TAI-REx/black-hat-rust",
"path": "/ch_10/client/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(_) = cli.subcommand_matches(cli::TOKEN) {
cli::token::run()?;
} else if let Some(_) = cli.subcommand_matches(cli::LIST) {
let config = Config::load()?;
cli::list::run(config)?;
}
Ok(())
}<|fim_prefix|>// repo: TAI-REx/black-hat-rust path: /ch_10/client... | code_fim | hard | {
"lang": "rust",
"repo": "TAI-REx/black-hat-rust",
"path": "/ch_10/client/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>om_end.to(0.0, 4.0);
let mut top_ctrl_line_end = bottom_origin.to_point(bottom_ctrl_point, 3.0);
top_ctrl_line_end.rotate(90.0, bottom_origin);
let top_ctrl_line = top_origin.to(-6.0, 0.0).line_to(top_ctrl_line_end);
let top_3rd_point = top_ctrl_line.parallel(0.2).right.mid... | code_fim | hard | {
"lang": "rust",
"repo": "sm921/pattern-making",
"path": "/clothes/src/pattern/shirt/collar/stand_collar.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>Bezier::new_with_t(
&vec![
bottom_origin.mirror(mirror_line),
top_end.mirror(mirror_line),
top_3rd_point.mirror(mirror_line),
top_origin,
top_3rd_point,
top_end,
bottom_origin,
... | code_fim | hard | {
"lang": "rust",
"repo": "sm921/pattern-making",
"path": "/clothes/src/pattern/shirt/collar/stand_collar.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sm921/pattern-making path: /clothes/src/pattern/shirt/collar/stand_collar.rs
use pmdraw::shapes::{bezier::Bezier, point::Point};
use crate::pattern::{common::pattern::Pattern, measurements::Cm};
pub struct StandCollar {
pub pattern: Pattern,
}
impl StandCollar {
/// - placket_width - ... | code_fim | hard | {
"lang": "rust",
"repo": "sm921/pattern-making",
"path": "/clothes/src/pattern/shirt/collar/stand_collar.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: D0ntPanic/tpscube path: /src/style.rs
use crate::theme::Theme;
use egui::{
epaint::Shadow,
style::{Selection, Visuals, WidgetVisuals, Widgets},
Color32, Stroke,
};
pub fn base_visuals() -> Visuals {
Visuals {
dark_mode: true,
widgets: Widgets {
nonint... | code_fim | hard | {
"lang": "rust",
"repo": "D0ntPanic/tpscube",
"path": "/src/style.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn content_visuals() -> Visuals {
let mut result = base_visuals();
result.widgets.noninteractive.bg_fill = Theme::BackgroundDark.into();
result
}
pub fn side_visuals() -> Visuals {
let mut result = base_visuals();
result.widgets.noninteractive.bg_fill = Theme::Background.into();
... | code_fim | hard | {
"lang": "rust",
"repo": "D0ntPanic/tpscube",
"path": "/src/style.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emiflake/thruster path: /src/geometry/plane.rs
use crate::algebra::prelude::*;
use crate::geometry::{geometry_information::GeometryInformation, shape::Shape};
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Plane {
pub origin: Point3,
pub normal: Normal,
}
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "emiflake/thruster",
"path": "/src/geometry/plane.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Shape for Plane {
fn intersect(&self, ray: &Ray) -> Option<GeometryInformation> {
let t = comb::dot(&(self.origin - ray.origin), &self.normal)
/ comb::dot(&self.normal, &ray.direction);
if t < 0.001 {
None
} else {
let p = ray.origin + (... | code_fim | medium | {
"lang": "rust",
"repo": "emiflake/thruster",
"path": "/src/geometry/plane.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// // REVIEW: Module is being cloned in err case... should test Module still works as expected...
// }
// #[test]
// fn test_get_function_value() {
// let context = Context::create();
// let builder = context.create_builder();
// let module = context.create_module("errors_abound");
// ... | code_fim | hard | {
"lang": "rust",
"repo": "TheDan64/inkwell",
"path": "/tests/all/test_execution_engine.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TheDan64/inkwell path: /tests/all/test_execution_engine.rs
use inkwell::context::Context;
use inkwell::execution_engine::FunctionLookupError;
use inkwell::targets::{InitializationConfig, Target};
use inkwell::{AddressSpace, IntPredicate, OptimizationLevel};
type Thunk = unsafe extern "C" fn();
... | code_fim | hard | {
"lang": "rust",
"repo": "TheDan64/inkwell",
"path": "/tests/all/test_execution_engine.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// #[test]
// fn test_get_function_value() {
// let context = Context::create();
// let builder = context.create_builder();
// let module = context.create_module("errors_abound");
// // let mut execution_engine = ExecutionEngine::create_jit_from_module(module, 0);
// let mut execution_... | code_fim | hard | {
"lang": "rust",
"repo": "TheDan64/inkwell",
"path": "/tests/all/test_execution_engine.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(number_to_symbol(0) == 'A');
assert!(number_to_symbol(1) == 'C');
assert!(number_to_symbol(2) == 'G');
assert!(number_to_symbol(3) == 'T');
}
}
#[cfg(test)]
mod symbol_to_number_test {
use super::symbol_to_number;
#[test]
fn it_maps_uppercase() {
assert!(symbol_to_nu... | code_fim | hard | {
"lang": "rust",
"repo": "Istar-Eldritch/biot",
"path": "/src/biot/frequent_words.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.