text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: rust-bakery/nom-derive path: /tests/enums.rs
#[allow(unused_imports)]
#[macro_use]
extern crate pretty_assertions;
use nom::bytes::streaming::take;
use nom_derive::*;
#[derive(Debug, PartialEq, Eq, Clone, Copy, Nom)]
pub struct MessageType(pub u8);
/// An enum with unnamed fields
#[derive(Deb... | code_fim | hard | {
"lang": "rust",
"repo": "rust-bakery/nom-derive",
"path": "/tests/enums.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// An unnamed enum with a unit struct field
#[derive(Debug, PartialEq, Nom)]
#[nom(Selector = "u8")]
pub enum U9 {
#[nom(Selector = "0")]
Field1,
#[nom(Selector = "1")]
Field2(u32),
}
#[test]
fn test_enum_unnamed() {
let input = b"\x00\x00\x00\x02";
let res = U1::parse(input, Mes... | code_fim | hard | {
"lang": "rust",
"repo": "rust-bakery/nom-derive",
"path": "/tests/enums.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /src/Windows/Phone/PersonalInformation/mod.rs
ryResultOrdering {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for ContactQueryResultOrdering {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for C... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/src/Windows/Phone/PersonalInformation/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /src/Windows/Phone/PersonalInformation/mod.rs
= ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).14)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn SetHonor... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/src/Windows/Phone/PersonalInformation/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
texture_manager,
mesh_manager,
}
}
}<|fim_prefix|>// repo: Hscowef/wgpu-renderer path: /src/ressource_manager/mod.rs
pub mod mesh;
pub mod texture;
use mesh::MeshManager;
use texture::TextureManager;
use std::sync::{Arc, Mutex};
pub struct RessourceMa... | code_fim | hard | {
"lang": "rust",
"repo": "Hscowef/wgpu-renderer",
"path": "/src/ressource_manager/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hscowef/wgpu-renderer path: /src/ressource_manager/mod.rs
pub mod mesh;
pub mod texture;
use mesh::MeshManager;
use texture::TextureManager;
<|fim_suffix|>pub struct RessourceManager {
pub texture_manager: TextureManager,
pub mesh_manager: MeshManager,
}
impl RessourceManager {
pu... | code_fim | medium | {
"lang": "rust",
"repo": "Hscowef/wgpu-renderer",
"path": "/src/ressource_manager/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> transaction.execute(
"INSERT INTO ChallengeCompletion (challenge_id, person_id, image_uuid)
VALUES ($1, $2, $3)",
&[&challenge_id, &user_id.0, &uuid],
)?;
transaction.execute(
"UPDATE ActiveChallenge SET completed = TRUE
where challenge_id = $1 and pers... | code_fim | hard | {
"lang": "rust",
"repo": "chipshort/homeAdv",
"path": "/backend/src/challenge.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut resp = Response::new();
if res.len() < 1 || res.get(0).get::<usize, bool>(0) != false {
resp.set_status(Status::new(403, "You may not complete a Challenge twice"));
return Ok(resp);
}
let challenge_id_db: i32 = res.get(0).get(1);
if challenge_id_db != challenge... | code_fim | hard | {
"lang": "rust",
"repo": "chipshort/homeAdv",
"path": "/backend/src/challenge.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chipshort/homeAdv path: /backend/src/challenge.rs
use crate::account::UserId;
use crate::MainDbCon;
use rocket::http::Status;
use rocket::response::Response;
use rocket_contrib::json::Json;
#[derive(Serialize)]
pub struct ChallengeResponse {
id: i32,
title: String,
topic: String,
... | code_fim | hard | {
"lang": "rust",
"repo": "chipshort/homeAdv",
"path": "/backend/src/challenge.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: werkshy/pickup path: /pickup-rust/src/cli.rs
use clap::{Parser, Subcommand};
const DEFAULT_MUSIC_DIR: &str = "../music";
const DEFAULT_PORT: u32 = 9090;
// Clap CLI definition struct
// TODO:
// Can change the music-dir arg to PathBuf
// Allow overriding ignores
// Add subcommands e.g.
// d... | code_fim | medium | {
"lang": "rust",
"repo": "werkshy/pickup",
"path": "/pickup-rust/src/cli.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Refresh the music files (can be slow on network drives).
Refresh {},
/// Start the HTTP server
Serve {
#[arg(short, long, default_value_t = DEFAULT_PORT)]
port: u32,
},
}<|fim_prefix|>// repo: werkshy/pickup path: /pickup-rust/src/cli.rs
use clap::{Parser, Subcomma... | code_fim | hard | {
"lang": "rust",
"repo": "werkshy/pickup",
"path": "/pickup-rust/src/cli.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Start the HTTP server
Serve {
#[arg(short, long, default_value_t = DEFAULT_PORT)]
port: u32,
},
}<|fim_prefix|>// repo: werkshy/pickup path: /pickup-rust/src/cli.rs
use clap::{Parser, Subcommand};
const DEFAULT_MUSIC_DIR: &str = "../music";
const DEFAULT_PORT: u32 = 9090;... | code_fim | medium | {
"lang": "rust",
"repo": "werkshy/pickup",
"path": "/pickup-rust/src/cli.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Keats/tokio path: /src/proto/pipeline/mod.rs
//! A dispatcher for pipelining protocols
//!
//! This module contains reusable components for quickly implementing clients
//! and servers for pipeline based protocols.
//!
//! # Pipelining
//!
//! Protocol pipelining is a technique in which multiple... | code_fim | hard | {
"lang": "rust",
"repo": "Keats/tokio",
"path": "/src/proto/pipeline/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Messages read from the transport
type Out: Send + 'static;
/// Errors
type Error: Send + 'static;
/// Transport returned
type Item: Transport<In = Self::In, Out = Self::Out, Error = Self::Error>;
/// Create and return a new `Transport`
fn new_transport(&self, socket:... | code_fim | hard | {
"lang": "rust",
"repo": "Keats/tokio",
"path": "/src/proto/pipeline/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if pack_file_path.exists() {
error("A pack.toml file already exists in this directory!");
return Ok(())
}
pack.save(pack_file_path)?;
complete("Generated pack.toml!");
Ok(())
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let opt: Opt = Opt::from_args();... | code_fim | hard | {
"lang": "rust",
"repo": "Tom-The-Geek/pack-it",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tom-The-Geek/pack-it path: /src/main.rs
use crate::pack::{ModPack, ModMetadata, ModUpdateMetadata};
use structopt::StructOpt;
use std::path::Path;
use crate::util::{error, complete, warning, hash_from_url, info};
use crate::sources::curseforge::CurseforgeClient;
use crate::sources::modrinth::Mod... | code_fim | hard | {
"lang": "rust",
"repo": "Tom-The-Geek/pack-it",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // #[structopt(help = "test curseforge lookup")]
// CFTest,
// #[structopt(help = "test modrinth lookup")]
// MRTest,
}
async fn init_pack() -> anyhow::Result<()> {
let pack_file_path = Path::new("pack.toml");
if pack_file_path.exists() {
error("A pack.toml file already ex... | code_fim | hard | {
"lang": "rust",
"repo": "Tom-The-Geek/pack-it",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rcastill/rumqtt-reqres path: /examples/server.rs
use std::{sync::Arc, time::Duration};
use rumqtt_reqres::{Reaction, Service};
use rumqttc::{AsyncClient, MqttOptions};
use tokio::{sync::Mutex, time::sleep};
#[tokio::main(flavor = "current_thread")]
async fn main() {
env_logger::Builder::fr... | code_fim | hard | {
"lang": "rust",
"repo": "rcastill/rumqtt-reqres",
"path": "/examples/server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Respond to requests
// TODO: respond something meaningful
let resubh = Arc::new(Mutex::new(None));
loop {
match eventloop.poll().await {
Ok(ev) => match service.react(&ev).await {
Some(Reaction::Request(res)) => {
log::info!("Got r... | code_fim | hard | {
"lang": "rust",
"repo": "rcastill/rumqtt-reqres",
"path": "/examples/server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.info_list.insert_or_update(&config)?;
Ok(())
}
/// Attach all configured vsock device to the virtual machine instance.
pub fn attach_devices(
&mut self,
ctx: &mut DeviceOpContext,
) -> std::result::Result<(), StartMicroVmError> {
let epoll_mgr... | code_fim | hard | {
"lang": "rust",
"repo": "kata-containers/kata-containers",
"path": "/src/dragonball/src/device_manager/vsock_dev_mgr.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kata-containers/kata-containers path: /src/dragonball/src/device_manager/vsock_dev_mgr.rs
// Copyright (C) 2022 Alibaba Cloud. All rights reserved.
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Portions Copyright 2017 The ... | code_fim | hard | {
"lang": "rust",
"repo": "kata-containers/kata-containers",
"path": "/src/dragonball/src/device_manager/vsock_dev_mgr.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut device = Box::new(
Vsock::new(
info.config.guest_cid as u64,
Arc::new(info.config.queue_sizes()),
epoll_mgr.clone(),
)
.map_err(VirtioError::VirtioVsockError)
.ma... | code_fim | hard | {
"lang": "rust",
"repo": "kata-containers/kata-containers",
"path": "/src/dragonball/src/device_manager/vsock_dev_mgr.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andymaster01/advent-of-code-rust path: /src/general.rs
pub struct DayResult {
pub part1: i32,
<|fim_suffix|> {
DayResult { part1, part2 }
}
}<|fim_middle|> pub part2: i32,
}
impl DayResult {
pub fn new(part1: i32, part2: i32) -> DayResult | code_fim | medium | {
"lang": "rust",
"repo": "andymaster01/advent-of-code-rust",
"path": "/src/general.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>b fn new(part1: i32, part2: i32) -> DayResult {
DayResult { part1, part2 }
}
}<|fim_prefix|>// repo: andymaster01/advent-of-code-rust path: /src/general.rs
pub struct DayResult {
pub part1: i32,
<|fim_middle|> pub part2: i32,
}
impl DayResult {
pu | code_fim | easy | {
"lang": "rust",
"repo": "andymaster01/advent-of-code-rust",
"path": "/src/general.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut cycle = 1;
let mut reg_x = 1;
for command in commands {
for _ in 0..command.cycles() {
if reg_x >= (cycle % 40) - 2 && reg_x <= (cycle % 40) {
print!("#");
} else {
print!(" ");
}
if cycle % 40 ==... | code_fim | hard | {
"lang": "rust",
"repo": "klieth/advent-of-code",
"path": "/2022/d10/rust/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: klieth/advent-of-code path: /2022/d10/rust/src/main.rs
use std::num::ParseIntError;
use std::str::FromStr;
const TEST: &'static str = include_str!("../../test");
const INPUT: &'static str = include_str!("../../input");
#[derive(Debug)]
enum Day10Error {
ParseError(String),
}
impl From<Par... | code_fim | hard | {
"lang": "rust",
"repo": "klieth/advent-of-code",
"path": "/2022/d10/rust/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Error for VlqError {}
/// 0x7f, 127: The largest 7 bit number.
const MAX_7BIT: u8 = 0b0111_1111;
/// 0x80, 128: The highest bit is set, this bit indicates the last byte of a sequence.
pub(crate) const CONTINUE: u8 = 0b1000_0000;
fn encode_u32(mut value: u32) -> Vec<u8> {
if value == 0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "TechPersonYT/midi_file",
"path": "/src/core/vlq.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TechPersonYT/midi_file path: /src/core/vlq.rs
use std::convert::{TryFrom, TryInto};
use std::error::Error;
use std::fmt::{Debug, Display, Formatter};
#[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Hash)]
pub(crate) struct Vlq {
inner: u32,
}
impl Vlq {
pub(crate)... | code_fim | hard | {
"lang": "rust",
"repo": "TechPersonYT/midi_file",
"path": "/src/core/vlq.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) fn time_get(clock_id: types::Clockid) -> Result<types::Timestamp> {
let clock_id: ClockId = clock_id.into();
let timespec = clock_gettime(clock_id)?;
// convert to nanoseconds, returning EOVERFLOW in case of overflow; this is freelancing a bit
// from the spec but seems like it... | code_fim | hard | {
"lang": "rust",
"repo": "mashtizadeh/wasmtime",
"path": "/crates/wasi-common/src/sys/unix/clock.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> // convert to nanoseconds, returning EOVERFLOW in case of overflow; this is freelancing a bit
// from the spec but seems like it'll be an unusual situation to hit
(timespec.tv_sec as types::Timestamp)
.checked_mul(1_000_000_000)
.and_then(|sec_ns| sec_ns.checked_add(timespec.tv... | code_fim | medium | {
"lang": "rust",
"repo": "mashtizadeh/wasmtime",
"path": "/crates/wasi-common/src/sys/unix/clock.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mashtizadeh/wasmtime path: /crates/wasi-common/src/sys/unix/clock.rs
use crate::wasi::{types, Errno, Result};
use yanix::clock::{clock_getres, clock_gettime, ClockId};
pub(crate) fn res_get(clock_id: types::Clockid) -> Result<types::Timestamp> {
let clock_id: ClockId = clock_id.into();
... | code_fim | medium | {
"lang": "rust",
"repo": "mashtizadeh/wasmtime",
"path": "/crates/wasi-common/src/sys/unix/clock.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|>());
}
extern fn Init() -> v8::Function {
let tpl = v8::FunctionTemplate::New(Socket::New);
tpl.SetClassName("Socket");
tpl.SetInternalFieldCount(1);
tpl.SetPropertyMethod("connect", Socket::Connect);
tpl.SetPropertyMethod("disconnect", Socket::Disconnect);
tpl.GetFunction()
... | code_fim | hard | {
"lang": "rust",
"repo": "lexfro/rustjs",
"path": "/src/builtin/net.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lexfro/rustjs path: /src/builtin/net.rs
use util::v8;
// use tokio_proto::TcpClient;
struct Socket;
impl Socket {
extern fn New(info: v8::FunctionCallbackInfo) {
if info.IsConstructCall() {
info.GetReturnValue().Set(info.This());
}
}
extern fn Connect(info: v8::FunctionCall... | code_fim | hard | {
"lang": "rust",
"repo": "lexfro/rustjs",
"path": "/src/builtin/net.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: utrescu/AdventRust path: /advent03a/src/main.rs
#[macro_use]
extern crate lazy_static;
extern crate regex;
use regex::Regex;
use std::collections::HashMap;
use std::str::FromStr;
#[derive(Debug, Clone, Copy)]
pub struct Rectangle {
pub id: usize,
pub x: usize,
pub y: usize,
pub ... | code_fim | medium | {
"lang": "rust",
"repo": "utrescu/AdventRust",
"path": "/advent03a/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Ara m'agrada i tot aquest sstema de llegir el fitxer
let inputdata = include_str!("input");
let rectangles: Vec<Rectangle> = inputdata
.lines()
.map(Rectangle::from_str)
.map(Result::unwrap)
.collect();
let mut ocupacio = HashMap::new();
for rectan... | code_fim | hard | {
"lang": "rust",
"repo": "utrescu/AdventRust",
"path": "/advent03a/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let minefield: Vec<Vec<char>> = minefield
.iter()
.map(|l| l.chars().collect())
.collect();
let mut result: Vec<String> = Vec::with_capacity(minefield.len());
for i in 0..minefield.len() {
let mut row = String::from("");
for j in 0..minefield[0].len() ... | code_fim | medium | {
"lang": "rust",
"repo": "them0ntem/exercism-rust",
"path": "/minesweeper/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: them0ntem/exercism-rust path: /minesweeper/src/lib.rs
use std::char;
const OFFSETS: [(i8, i8); 8] = [
(-1, -1),
(0, -1),
(1, -1),
(-1, 0),
(1, 0),
(-1, 1),
(0, 1),
(1, 1),
];
<|fim_suffix|>pub fn annotate(minefield: &[&str]) -> Vec<String> {
println!("{:?}",... | code_fim | medium | {
"lang": "rust",
"repo": "them0ntem/exercism-rust",
"path": "/minesweeper/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JoshiDhima/Bathbot path: /src/pagination/common.rs
use super::{Pages, Pagination};
use crate::{
commands::osu::{CommonScoreEntry, CommonUser},
embeds::CommonEmbed,
BotResult,
};
use smallvec::SmallVec;
use twilight_model::channel::Message;
<|fim_suffix|> self.pages.per_page... | code_fim | hard | {
"lang": "rust",
"repo": "JoshiDhima/Bathbot",
"path": "/src/pagination/common.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn msg(&self) -> &Message {
&self.msg
}
fn pages(&self) -> Pages {
self.pages
}
fn pages_mut(&mut self) -> &mut Pages {
&mut self.pages
}
fn single_step(&self) -> usize {
self.pages.per_page
}
async fn build_page(&mut self) -> BotResu... | code_fim | hard | {
"lang": "rust",
"repo": "JoshiDhima/Bathbot",
"path": "/src/pagination/common.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/homectl path: /types/src/device.rs
use std::collections::HashMap;
use super::{integration::IntegrationId, scene::SceneId};
use chrono::{DateTime, Utc};
use palette::Hsv;
use rocket::request::FromParam;
use serde::{Deserialize, Serialize};
macro_attr! {
#[derive(Clone, Debug, Deseri... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/homectl",
"path": "/types/src/device.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub activation_time: DateTime<Utc>,
}
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct Device<T = DeviceState> {
pub id: DeviceId,
pub name: String,
pub integration_id: IntegrationId,
pub scene: Option<DeviceSceneState>,
pub state: T,
pub locked: bool,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/homectl",
"path": "/types/src/device.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dsolisherrera/rust_exercises path: /avg_median_mode/src/main.rs
use std::collections::HashMap;
fn average(numbers : &Vec<i32>) -> i32{
let size = numbers.len() as i32;
if size > 0{
let avg = numbers.iter().fold(0, |acc, x| acc + x);
return avg / size;
}
0
}
<|... | code_fim | hard | {
"lang": "rust",
"repo": "dsolisherrera/rust_exercises",
"path": "/avg_median_mode/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
println!("Avg {}", average(&numbers));
if let Some(x) = median(numbers.clone()){
println!("Median {}", x);
}
else{
println!("There is no median");
}
println!("Mode {}", mode(&numbers));
}<|fim_prefix|>// repo: dsolisherrera/rust_exercises path: /avg_median_mode/... | code_fim | hard | {
"lang": "rust",
"repo": "dsolisherrera/rust_exercises",
"path": "/avg_median_mode/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/xim-rs path: /src/xlib.rs
use ahash::AHashMap;
use std::ffi::CStr;
use std::mem::MaybeUninit;
use std::rc::Rc;
use std::sync::Arc;
use std::{convert::TryInto, os::raw::c_long};
use crate::{
client::{handle_request, ClientCore, ClientError, ClientHandler},
Atoms,
};
use x11_dl::x... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/xim-rs",
"path": "/src/xlib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> handle_request(self, handler, req)?;
(self.x.xlib().XFree)(prop as _);
}
} else if msg.format == 8 {
let bytes = msg.data.as_bytes();
let data: &[u8] =
unsafe { std::slice::from_raw_parts(bytes.as_ptr() as _, byte... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/xim-rs",
"path": "/src/xlib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait BkNodeMut: BkNode {
fn set_child_node(&mut self, distance: Dist, node: Self);
fn child_at_mut(&mut self, dist: Dist) -> Option<&mut Self>;
}<|fim_prefix|>// repo: pwildani/bkchainsaw path: /src/bknode.rs
use crate::Dist;
use std::vec::Vec;
pub trait BkNode {
type Key;
fn key(&... | code_fim | medium | {
"lang": "rust",
"repo": "pwildani/bkchainsaw",
"path": "/src/bknode.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// Needs RFC 1598: GATs: because the child is not copyable and is owned by this code (or
// rather, by its allocator)
// fn children_iter(&self) -> impl Iterator<Item = (Dist, &Self)>;
}
pub trait BkNodeMut: BkNode {
fn set_child_node(&mut self, distance: Dist, node: Self);
fn child_... | code_fim | medium | {
"lang": "rust",
"repo": "pwildani/bkchainsaw",
"path": "/src/bknode.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pwildani/bkchainsaw path: /src/bknode.rs
use crate::Dist;
use std::vec::Vec;
pub trait BkNode {
type Key;
fn key(&self) -> &Self::Key;
fn has_child_at(&self, dist: Dist) -> bool;
<|fim_suffix|>
// Needs RFC 1598: GATs: because the child is not copyable and is owned by this code... | code_fim | medium | {
"lang": "rust",
"repo": "pwildani/bkchainsaw",
"path": "/src/bknode.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_width(&self) -> i32 {
self.max_x - self.min_x + 1
}
pub fn get_height(&self) -> i32 {
self.max_y - self.min_y + 1
}
}
fn to_float(integer: i32) -> f32 {
integer as f32 / 10_000.0
}
fn from_float(floating: f32) -> i32 {
(floating * 10_000.0) as i32
}
#... | code_fim | hard | {
"lang": "rust",
"repo": "knokko/wasmuri-core",
"path": "/src/util/region.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: knokko/wasmuri-core path: /src/util/region.rs
/// Represents a rectangular part of the viewport.
#[derive(Clone,Copy,std::fmt::Debug,PartialEq,Eq)]
pub struct Region {
min_x: i32,
min_y: i32,
max_x: i32,
max_y: i32
}
impl Region {
/// Creates a new (rectangular) region with... | code_fim | hard | {
"lang": "rust",
"repo": "knokko/wasmuri-core",
"path": "/src/util/region.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Edge cases
assert_eq!(vec![region], region.get_uncovered_regions(&Vec::new()));
assert_eq!(Vec::<Region>::new(), region.get_uncovered_regions(&vec![region]));
// 1 partially overlapping region
assert_eq!(vec![Region::new(20, 0, 40, 50)], regi... | code_fim | hard | {
"lang": "rust",
"repo": "knokko/wasmuri-core",
"path": "/src/util/region.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
Self::Empty => f.write_str("empty input"),
Self::MissingKey => f.write_str("missing key"),
Self::MissingValue => f.write_str("missing value"),
}
}
}
impl FromStr for Entry {
type Err = ParseError;
fn from_str(s: &str) -> Result... | code_fim | hard | {
"lang": "rust",
"repo": "jguhlin/noodles",
"path": "/noodles-gff/src/record/attributes/entry.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut components = s.splitn(2, SEPARATOR);
let key = components
.next()
.and_then(|s| if s.is_empty() { None } else { Some(s.into()) })
.ok_or(ParseError::MissingKey)?;
let value = components
.next()
.map(|s| s.into())... | code_fim | hard | {
"lang": "rust",
"repo": "jguhlin/noodles",
"path": "/noodles-gff/src/record/attributes/entry.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jguhlin/noodles path: /noodles-gff/src/record/attributes/entry.rs
//! GFF record attribute entry.
use std::{error, fmt, str::FromStr};
const SEPARATOR: char = '=';
/// A GFF record attribute entry.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Entry {
key: String,
value: String,
}... | code_fim | hard | {
"lang": "rust",
"repo": "jguhlin/noodles",
"path": "/noodles-gff/src/record/attributes/entry.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adrianwithah/intercom-example path: /intercom-common/src/model/comstruct.rs
use ::prelude::*;
use super::*;
use super::macros::*;
use ::guid::GUID;
use ::syn::{Ident, Visibility};
intercom_attribute!(
ComStructAttr< ComStructAttrParam, Ident > {
clsid : StrOption,
}
);
/// De... | code_fim | hard | {
"lang": "rust",
"repo": "adrianwithah/intercom-example",
"path": "/intercom-common/src/model/comstruct.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cls = ComStruct::parse(
"not used",
quote!( clsid = None ),
"struct EmptyType;" )
.expect( "com_class attribute parsing failed" );
assert_eq!( cls.name(), "EmptyType" );
assert_eq!( cls.clsid(), &None );
assert_eq!( c... | code_fim | hard | {
"lang": "rust",
"repo": "adrianwithah/intercom-example",
"path": "/intercom-common/src/model/comstruct.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MSDimos/leetcode-rust2018 path: /Q32-longest-valid-parentheses/examples/test.rs
use Q32_longest_valid_parentheses::Solution;
<|fim_suffix|> println!("{}", len);
}<|fim_middle|>fn main() {
let len = Solution::longest_valid_parentheses(String::from("()()()(())"));
| code_fim | medium | {
"lang": "rust",
"repo": "MSDimos/leetcode-rust2018",
"path": "/Q32-longest-valid-parentheses/examples/test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let len = Solution::longest_valid_parentheses(String::from("()()()(())"));
println!("{}", len);
}<|fim_prefix|>// repo: MSDimos/leetcode-rust2018 path: /Q32-longest-valid-parentheses/examples/test.rs
use Q32_longest_valid_parentheses::Solution;
<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "MSDimos/leetcode-rust2018",
"path": "/Q32-longest-valid-parentheses/examples/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>DawgValue;
pub use self::value::HH;
pub use self::value::HHH;<|fim_prefix|>// repo: irbis-labs/rsmorphy path: /src/dawg/mod.rs
pub mod completer;
pub mod dawg;
pub mod dictionary;
pub mod guide;
pub mod units;
pub mod value;
pub use self::dawg::Co<|fim_middle|>mpletionDawg;
pub use self::dawg::Dawg;
pub... | code_fim | medium | {
"lang": "rust",
"repo": "irbis-labs/rsmorphy",
"path": "/src/dawg/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: irbis-labs/rsmorphy path: /src/dawg/mod.rs
pub mod completer;
pub mod dawg;
pub mod dictionary;
pub mod<|fim_suffix|>mpletionDawg;
pub use self::dawg::Dawg;
pub use self::value::DawgValue;
pub use self::value::HH;
pub use self::value::HHH;<|fim_middle|> guide;
pub mod units;
pub mod value;
pub ... | code_fim | medium | {
"lang": "rust",
"repo": "irbis-labs/rsmorphy",
"path": "/src/dawg/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Part 1: {}", sum_expressions("input.txt", LeftToRight));
println!("Part 2: {}", sum_expressions("input.txt", AddBeforeTimes));
}<|fim_prefix|>// repo: jhungerford/adventofcode-2020 path: /day18/src/main.rs
use day18::sum_expressions;
use day18::Mode::{LeftToRight, AddBeforeTimes};
<|fi... | code_fim | easy | {
"lang": "rust",
"repo": "jhungerford/adventofcode-2020",
"path": "/day18/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jhungerford/adventofcode-2020 path: /day18/src/main.rs
use day18::sum_expressions;
use day18::Mode::{LeftToRight, AddBeforeTimes};
<|fim_suffix|> println!("Part 1: {}", sum_expressions("input.txt", LeftToRight));
println!("Part 2: {}", sum_expressions("input.txt", AddBeforeTimes));
}<|fi... | code_fim | easy | {
"lang": "rust",
"repo": "jhungerford/adventofcode-2020",
"path": "/day18/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut stack: Stack<i64> = Stack::new();
stack.pop().unwrap();
}<|fim_prefix|>// repo: locez/data-structure path: /tests/stack_test.rs
extern crate data_structure;
use data_structure::stack::Stack;
#[test]
fn stack_test() {
<|fim_middle|> let mut stack: Stack<i64> = Stack::new();
stack.pu... | code_fim | hard | {
"lang": "rust",
"repo": "locez/data-structure",
"path": "/tests/stack_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
#[should_panic]
fn empty_pop() {
let mut stack: Stack<i64> = Stack::new();
stack.pop().unwrap();
}<|fim_prefix|>// repo: locez/data-structure path: /tests/stack_test.rs
extern crate data_structure;
use data_structure::stack::Stack;
#[test]
fn stack_test() {
<|fim_middle|> let mut stack... | code_fim | hard | {
"lang": "rust",
"repo": "locez/data-structure",
"path": "/tests/stack_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: locez/data-structure path: /tests/stack_test.rs
extern crate data_structure;
use data_structure::stack::Stack;
#[test]
fn stack_test() {
<|fim_suffix|>#[test]
#[should_panic]
fn empty_pop() {
let mut stack: Stack<i64> = Stack::new();
stack.pop().unwrap();
}<|fim_middle|> let mut stack... | code_fim | hard | {
"lang": "rust",
"repo": "locez/data-structure",
"path": "/tests/stack_test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PedroDiogo/AdventOfCode2018 path: /day5_problem2/src/main.rs
mod inputs;
fn main() {
let file_name = inputs::get_input_file_name();
let initial_polymer = inputs::read_input_file(file_name);
let best_result = get_best_polymer_size_by_replacing_one_unit(&initial_polymer);
println... | code_fim | hard | {
"lang": "rust",
"repo": "PedroDiogo/AdventOfCode2018",
"path": "/day5_problem2/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let reacted_polymer = polymer.into_iter().collect();
return reacted_polymer;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_get_reacted_polymer_simple() {
assert_eq!("", get_reacted_polymer("aA"));
}
#[test]
fn test_get_reacted_polymer_simple_reaction()... | code_fim | hard | {
"lang": "rust",
"repo": "PedroDiogo/AdventOfCode2018",
"path": "/day5_problem2/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!("", get_reacted_polymer("abBA"));
}
#[test]
fn test_get_reacted_polymer_no_reaction() {
assert_eq!("abAB", get_reacted_polymer("abAB"));
}
#[test]
fn test_get_reacted_polymer_other_no_reaction() {
assert_eq!("aabAAB", get_reacted_polymer("aabAAB... | code_fim | hard | {
"lang": "rust",
"repo": "PedroDiogo/AdventOfCode2018",
"path": "/day5_problem2/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jimizai/passwd path: /src/responses.rs
use chrono::prelude::*;
use diesel::result::Error as DieselError;
use rocket::http::{ContentType, Status};
use rocket::request::Request;
use rocket::response::{Responder, Response};
use rocket_contrib::json;
use rocket_contrib::json::JsonValue;
use serde_js... | code_fim | hard | {
"lang": "rust",
"repo": "jimizai/passwd",
"path": "/src/responses.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn accepted() -> APIResponse {
APIResponse {
msg: String::from("accepted"),
data: json!(null),
code: 403,
total: None,
}
}
pub fn validate_error() -> APIResponse {
APIResponse {
msg: String::from("validate error"),
data: json!(null),
... | code_fim | hard | {
"lang": "rust",
"repo": "jimizai/passwd",
"path": "/src/responses.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Label::new("Flex Basis: 200px, Flex Grow: 0.0").build(state, window, |builder| {
builder
.set_flex_basis(Length::Pixels(200.0))
.set_background_color(Color::rgb(120, 50, 50))
});
Label::new("Flex Basis: 100px, Flex Grow: 2.0").build(stat... | code_fim | hard | {
"lang": "rust",
"repo": "SonicZentropy/tuix",
"path": "/examples/layout/flex_grow.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SonicZentropy/tuix path: /examples/layout/flex_grow.rs
use tuix::*;
fn main() {
let app = Application::new(|win_desc, state, window| {
window
.set_background_color(state, Color::white())
.set_flex_direction(state, FlexDirection::Row);
<|fim_suffix|> L... | code_fim | hard | {
"lang": "rust",
"repo": "SonicZentropy/tuix",
"path": "/examples/layout/flex_grow.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Label::new("Flex Basis: 100px, Flex Grow: 2.0").build(state, window, |builder| {
builder
.set_flex_grow(2.0)
.set_flex_basis(Length::Pixels(100.0))
.set_background_color(Color::rgb(50, 120, 50))
});
Label::new("Flex Basis... | code_fim | hard | {
"lang": "rust",
"repo": "SonicZentropy/tuix",
"path": "/examples/layout/flex_grow.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>-{}.exe", target);
std::fs::copy(file, new_file).unwrap();
tauri_build::build()
}<|fim_prefix|>// repo: lazytiger/trojan-rs path: /trojan-client/src-tauri/build.rs
fn main() {
let profile = std::env::var("PROFILE").unwrap();
let target = std::env::var("TARGET").unwrap();
let file = fo... | code_fim | medium | {
"lang": "rust",
"repo": "lazytiger/trojan-rs",
"path": "/trojan-client/src-tauri/build.rs",
"mode": "spm",
"license": "LicenseRef-scancode-free-unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lazytiger/trojan-rs path: /trojan-client/src-tauri/build.rs
fn main() {
let profile = std::env::var("PROFILE").unwrap();
let target = std::env::var("TARGET").unwrap();
let file = format!("../../target/{}/trojan.exe", profile);<|fim_suffix|>-{}.exe", target);
std::fs::copy(file, n... | code_fim | medium | {
"lang": "rust",
"repo": "lazytiger/trojan-rs",
"path": "/trojan-client/src-tauri/build.rs",
"mode": "psm",
"license": "LicenseRef-scancode-free-unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
println!("cargo:rerun-if-changed={}", file);
let new_file = format!("libs/trojan-{}.exe", target);
std::fs::copy(file, new_file).unwrap();
tauri_build::build()
}<|fim_prefix|>// repo: lazytiger/trojan-rs path: /trojan-client/src-tauri/build.rs
fn main() {
let profile = std::env::var(... | code_fim | medium | {
"lang": "rust",
"repo": "lazytiger/trojan-rs",
"path": "/trojan-client/src-tauri/build.rs",
"mode": "spm",
"license": "LicenseRef-scancode-free-unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dansoper/adventofcode path: /2021/day2/src/main.rs
fn main() {
let list: Vec<Instruction> = include_str!("input.txt")
.lines()
.map(parse_to_instruction)
.collect();
let position = process_instructions(&list);
println!("Part 1 multiple is {}", position.depth ... | code_fim | hard | {
"lang": "rust",
"repo": "dansoper/adventofcode",
"path": "/2021/day2/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match str {
"down" => Direction::Down,
"up" => Direction::Up,
"forward" => Direction::Forward,
&_ => Direction::Up
}
}
fn process_instructions(list: &Vec<Instruction>) -> Position {
let mut pos = Position {
horizontal: 0, depth: 0
};
for i in 0 ... | code_fim | hard | {
"lang": "rust",
"repo": "dansoper/adventofcode",
"path": "/2021/day2/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn process_instructions(list: &Vec<Instruction>) -> Position {
let mut pos = Position {
horizontal: 0, depth: 0
};
for i in 0 .. list.len() {
let instruction = &list[i];
if Direction::Up == instruction.direction {
pos.depth = pos.depth - instruction.distance... | code_fim | hard | {
"lang": "rust",
"repo": "dansoper/adventofcode",
"path": "/2021/day2/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/tin path: /src/ir/component/ty/error.rs
use std::fmt;
use specs::Component;
use specs::VecStorage;
use crate::ir::component::ty;
use crate::ir::component::ty::class;
#[derive(Component, Clone, Debug, Eq, Fail, PartialEq, VisitEntities, VisitEntitiesMut)]
#[storage(VecStorage)]
pub str... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/tin",
"path": "/src/ir/component/ty/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "expected ")?;
self.expected.fmt(f)?;
write!(f, " but got `")?;
self.actual.fmt(f)?;
write!(f, "`")?;
Ok(())
}
}
impl fmt::Display for ExpectedType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/tin",
"path": "/src/ir/component/ty/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Riduidel/rrss2imap path: /src/settings.rs
use imap::error::Result;
use imap::Session;
use std::{thread, time};
use super::config::Config;
/// Secured connection or not ?
/// Whichever is chosen, user has to give the port as parameter
#[derive(Debug, Clone, Deserialize, Serialize, Parti... | code_fim | hard | {
"lang": "rust",
"repo": "Riduidel/rrss2imap",
"path": "/src/settings.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Store-level config
#[derive(Debug, Deserialize, Serialize)]
pub struct Settings {
/// when set to true, no reading statis will be persisted.
/// As a consequence, messages may be read more than once
#[serde(
skip_serializing_if = "Settings::is_false",
default = "Sett... | code_fim | hard | {
"lang": "rust",
"repo": "Riduidel/rrss2imap",
"path": "/src/settings.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
flip_horizontal(*BOARD1),
Board::new([
[0, 0, 0, 1, 1, 1],
[0, 0, 0, 1, 1, 0],
[0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0]
... | code_fim | hard | {
"lang": "rust",
"repo": "maxencefrenette/pentarust",
"path": "/pentarust/src/game/board_symmetries.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maxencefrenette/pentarust path: /pentarust/src/game/board_symmetries.rs
use crate::game::Board;
macro_rules! map_board {
($a:ident, $b:ident) => {
pub fn $a(board: Board) -> Board {
Board {
player1: $b(board.player1),
player2: $b(board.pla... | code_fim | hard | {
"lang": "rust",
"repo": "maxencefrenette/pentarust",
"path": "/pentarust/src/game/board_symmetries.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: starblue/advent_of_code path: /a2020/src/bin/a202016.rs
use core::str::FromStr;
use std::collections::HashSet;
use std::fmt;
use std::io;
use std::io::Read;
use nom::bytes::complete::tag;
use nom::character::complete::char;
use nom::character::complete::digit1;
use nom::character::complete::li... | code_fim | hard | {
"lang": "rust",
"repo": "starblue/advent_of_code",
"path": "/a2020/src/bin/a202016.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.0
.iter()
.filter(|&&n| !rules.iter().any(|r| r.may_have_value(n)))
.sum::<i64>()
}
}
impl fmt::Display for Ticket {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut sep = "";
for n in &self.0 {
write!(f, "{... | code_fim | hard | {
"lang": "rust",
"repo": "starblue/advent_of_code",
"path": "/a2020/src/bin/a202016.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct IfLibShared {
pub inner: NonNull<if_softc_ctx>,
}
impl IfLibShared {
pub fn setup(&mut self, mactype: MacType) -> Result<(), String> {
e1000_println!();
// Common
self.isc_msix_bar = pcir_bar(EM_MSIX_BAR) as i32;
self.isc_tx_nsegments = EM_MAX_SCATTER as... | code_fim | hard | {
"lang": "rust",
"repo": "akamit91/rustkpi",
"path": "/rust/kmod-e1000/src/iflib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akamit91/rustkpi path: /rust/kmod-e1000/src/iflib.rs
use kernel;
use kernel::ptr::NonNull;
use kernel::sys::raw::*;
use kernel::prelude::v1::*;
use kernel::sys::iflib_sys::ifnet;
use kernel::sys::iflib_sys::ifmediareq;
use kernel::sys::iflib_sys::if_sethwtsomax;
use kernel::sys::iflib_sys::if_s... | code_fim | hard | {
"lang": "rust",
"repo": "akamit91/rustkpi",
"path": "/rust/kmod-e1000/src/iflib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub struct IfMedia {
pub inner: NonNull<ifmedia>, // iflib internal struct
}
impl IfMedia {
pub fn add(&mut self, mword: i32, data: i32, aux: *mut c_void) {
let ptr: *mut ifmedia = self.inner.as_ptr();
unsafe {
ifmedia_add(ptr, mword, data, aux);
... | code_fim | hard | {
"lang": "rust",
"repo": "akamit91/rustkpi",
"path": "/rust/kmod-e1000/src/iflib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dysquard/arb-os path: /src/compile/codegen.rs
let (lg, nl2, inner_might_continue) = mavm_codegen_if_arm(
inner_arm,
end_label,
code,
num_locals,
locals,
... | code_fim | hard | {
"lang": "rust",
"repo": "dysquard/arb-os",
"path": "/src/compile/codegen.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dysquard/arb-os path: /src/compile/codegen.rs
pr::TupleRef(tce, idx, _, loc) => {
let tce_type = tce.get_type();
let tuple_size = if let Type::Tuple(fields) = tce_type {
fields.len()
} else {
panic!("type-checking bug: tuple loo... | code_fim | hard | {
"lang": "rust",
"repo": "dysquard/arb-os",
"path": "/src/compile/codegen.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> import_func_map,
global_var_map,
prepushed_vals,
)
}
TypeCheckedExpr::StructMod(struc, index, val, t, loc) => {
let (lg, c, val_locals) = mavm_codegen_expr(
val,
code,
num_locals,
... | code_fim | hard | {
"lang": "rust",
"repo": "dysquard/arb-os",
"path": "/src/compile/codegen.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yanganto/m-prober path: /src/hostname/mod.rs
use std::fs;
use std::io;
const HOSTNAME_PATH: &str = "/proc/sys/kernel/hostname";
<|fim_suffix|> if s.ends_with('\n') {
s.remove(s.len() - 1);
}
Ok(s)
}<|fim_middle|>#[inline]
pub fn get_hostname() -> Result<String, io::Error> {... | code_fim | medium | {
"lang": "rust",
"repo": "yanganto/m-prober",
"path": "/src/hostname/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if s.ends_with('\n') {
s.remove(s.len() - 1);
}
Ok(s)
}<|fim_prefix|>// repo: yanganto/m-prober path: /src/hostname/mod.rs
use std::fs;
use std::io;
const HOSTNAME_PATH: &str = "/proc/sys/kernel/hostname";
<|fim_middle|>#[inline]
pub fn get_hostname() -> Result<String, io::Error> {... | code_fim | medium | {
"lang": "rust",
"repo": "yanganto/m-prober",
"path": "/src/hostname/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wuggen/julia path: /src/interface.rs
color_idx()] = hsv;
self.data.color[self.active_color_idx()] = self.active_color();
}
pub fn adjust_saturation(&mut self, amount: f32) {
let mut hsv = self.hsv_colors[self.active_color_idx()];
hsv.saturation += amount / 360.0;... | code_fim | hard | {
"lang": "rust",
"repo": "wuggen/julia",
"path": "/src/interface.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let monitor = events_loop.get_primary_monitor();
let phys_size = monitor.get_dimensions();
let log_size = phys_size.to_logical(monitor.get_hidpi_factor());
let min_dim = f64::min(log_size.width, log_size.height);
let win_dim = min_dim * 0.8;
let phys_min_... | code_fim | hard | {
"lang": "rust",
"repo": "wuggen/julia",
"path": "/src/interface.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wuggen/julia path: /src/interface.rs
amit::{Angle, Vec2, Vec4, Vector};
use palette::{Hsv, RgbHue, Srgb};
use crate::export::{ImgDimensions, JuliaExport};
use crate::image::{JuliaImage, JuliaImageError};
use crate::render::{JuliaRender, JuliaRenderError};
use crate::{JuliaContext, JuliaData};
... | code_fim | hard | {
"lang": "rust",
"repo": "wuggen/julia",
"path": "/src/interface.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn from_real<T>(data: T, frq: f64, market: String) -> Mifi<T>
where T: Handler
{
Mifi {
topic: "".to_string(),
frq: frq,
market: market,
history: Default::default(),
portfolio: Default::default(),
format: "".to_string(),
real: data,
... | code_fim | hard | {
"lang": "rust",
"repo": "yutiansut/mifi-rs",
"path": "/src/func.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yutiansut/mifi-rs path: /src/func.rs
use std::collections::BTreeMap;
use crate::base::Handler;
use crate::market::{CtpPro, Diff, FullData};
use crate::mifi::Mifi;
<|fim_suffix|>pub fn from_real<T>(data: T, frq: f64, market: String) -> Mifi<T>
where T: Handler
{
Mifi {
topic: ""... | code_fim | hard | {
"lang": "rust",
"repo": "yutiansut/mifi-rs",
"path": "/src/func.rs",
"mode": "psm",
"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.