text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: deathlyfrantic/project-euler path: /3.rs
/* determine the largest prime factor of the number 600,851,475,143.
* (a "prime factor" being a factor that is a prime number.)
*/
const NUMBER: f64 = 600851475143.0;
fn main() {
let mut prime: i64 = 0;
let mut factor1: i64 = get_start(NUMBER... | code_fim | medium | {
"lang": "rust",
"repo": "deathlyfrantic/project-euler",
"path": "/3.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akiles/embassy path: /embassy-time/src/instant.rs
use core::fmt;
use core::ops::{Add, AddAssign, Sub, SubAssign};
use super::{driver, Duration, GCD_1K, GCD_1M, TICK_HZ};
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
/// An I... | code_fim | hard | {
"lang": "rust",
"repo": "akiles/embassy",
"path": "/embassy-time/src/instant.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let freqs = coding::Frequencies::read(&mut input_file)?;
let tree = coding::HuffTree::from_freqs(&freqs);
let mut reader = coding::HuffReader::new(&tree);
for maybe_byte in input_file.bytes() {
let byte = maybe_byte?;
let can_feed = reader.feed(byte, &mut output_writer)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "cronokirby/huffman-rs",
"path": "/src/cli.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cronokirby/huffman-rs path: /src/cli.rs
use std::fs::File;
use std::io;
use std::io::{Read, Seek};
use crate::structopt::StructOpt;
use crate::coding;
#[derive(Debug, StructOpt)]
#[structopt(name = "huffman")]
pub enum Opt {
#[structopt(name = "encode")]
/// Encode a file
Encode {
... | code_fim | hard | {
"lang": "rust",
"repo": "cronokirby/huffman-rs",
"path": "/src/cli.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn decode(input: String, output: String) -> io::Result<()> {
let mut input_file = File::open(input)?;
let output_file = File::create(output)?;
let mut output_writer = io::BufWriter::new(output_file);
let freqs = coding::Frequencies::read(&mut input_file)?;
let tree = coding::HuffTree:... | code_fim | hard | {
"lang": "rust",
"repo": "cronokirby/huffman-rs",
"path": "/src/cli.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LFalch/telda path: /src/mem.rs
use std::io::{stdin, stdout, Read, Write};
/// Memory below this address is used for IO mapping
pub const IO_MAPPING_CUTOFF: u16 = 0xffe0;
/// A memory request handler
///
/// Addresses up to `IO_MAPPING_CUTOFF` should be guaranteed to stay consistent between rea... | code_fim | hard | {
"lang": "rust",
"repo": "LFalch/telda",
"path": "/src/mem.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if addr < IO_MAPPING_CUTOFF {
if self.mem.len() <= addr as usize {
self.mem.resize(addr as usize + 1, 0);
}
self.mem[addr as usize] = val;
} else {
self.io.write(addr as u8, val);
}
}
}
impl Memory for [u8] {
... | code_fim | hard | {
"lang": "rust",
"repo": "LFalch/telda",
"path": "/src/mem.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eirproject/eir path: /libeir_diagnostics/src/lib.rs
#![feature(crate_visibility_modifier)]
mod codemap;
mod filename;
mod index;
mod source;
mod span;
pub use codespan::{ByteIndex, ByteOffset};
pub use codespan::{ColumnIndex, ColumnNumber, ColumnOffset};
pub use codespan::{Index, Offset};
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "eirproject/eir",
"path": "/libeir_diagnostics/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub type Diagnostic = codespan_reporting::diagnostic::Diagnostic<SourceId>;
pub type Label = codespan_reporting::diagnostic::Label<SourceId>;
pub trait ToDiagnostic {
fn to_diagnostic(&self) -> Diagnostic;
}<|fim_prefix|>// repo: eirproject/eir path: /libeir_diagnostics/src/lib.rs
#![feature(crate_v... | code_fim | medium | {
"lang": "rust",
"repo": "eirproject/eir",
"path": "/libeir_diagnostics/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: littlewang/yog path: /src/main.rs
#[macro_use] extern crate nickel;
use nickel::{Nickel, HttpRouter, JsonBody,StaticFilesHandler};
extern crate markdown;
extern crate mysql;
extern crate rustc_serialize;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::path::P... | code_fim | hard | {
"lang": "rust",
"repo": "littlewang/yog",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pool=conn_db();
let mut stmt0 = pool.prepare(r"INSERT INTO blog (title,content) VALUES (?,?,?)").unwrap();
stmt0.execute((blog.title,blog.content)).unwrap();
}
fn main() {
let mut server = Nickel::new();
//outprint html by markdown
let html : String = markdown::to_html("__I am ... | code_fim | hard | {
"lang": "rust",
"repo": "littlewang/yog",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: natebolam/coda path: /src/lib/marlin_plonk_bindings/stubs/src/lib.rs
extern crate libc;
/* Caml pointers */
pub mod caml_pointer;
/* Bigints */
pub mod bigint_256;
pub mod bigint_384;
/* Fields */
pub mod bn_382_fp;
pub mod bn_382_fq;
pub mod tweedle_fp;
pub mod tweedle_fq;
pub mod pasta_fp;
pu... | code_fim | hard | {
"lang": "rust",
"repo": "natebolam/coda",
"path": "/src/lib/marlin_plonk_bindings/stubs/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>index;
pub mod pasta_fq_plonk_verifier_index;
/* Proofs */
pub mod tweedle_fp_plonk_proof;
pub mod tweedle_fq_plonk_proof;
pub mod pasta_fp_plonk_proof;
pub mod pasta_fq_plonk_proof;
/* Oracles */
pub mod tweedle_fp_plonk_oracles;
pub mod tweedle_fq_plonk_oracles;
pub mod pasta_fp_plonk_oracles;
pub mod p... | code_fim | hard | {
"lang": "rust",
"repo": "natebolam/coda",
"path": "/src/lib/marlin_plonk_bindings/stubs/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akuczala/4d-game path: /src/gui.rs
use crate::components::*;
use crate::ecs_utils::Componentable;
use crate::fps::FPSFloat;
use crate::geometry::shape::RefShapes;
use crate::input::{Input, ShapeManipulationMode, ShapeManipulationState};
use crate::vector::{MatrixTrait, VectorTrait};
use glium::g... | code_fim | hard | {
"lang": "rust",
"repo": "akuczala/4d-game",
"path": "/src/gui.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn hello_world(_: &mut bool, ui: &mut Ui, ui_args: &mut UIArgs) {
use imgui::{Condition, Window};
ui.window("Debug info")
.position([20.0, 20.0], Condition::Appearing)
.size([300.0, 110.0], Condition::FirstUseEver)
.build(|| {
if let UIArgs::Test {
... | code_fim | hard | {
"lang": "rust",
"repo": "akuczala/4d-game",
"path": "/src/gui.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let renderer = Renderer::init(&mut imgui, display).expect("Failed to initialize renderer");
System {
imgui,
platform,
renderer,
font_size,
ui_args: UIArgs::None,
state: State::default(),
}
}
pub enum UIArgs {
None,
Test {
frame_d... | code_fim | hard | {
"lang": "rust",
"repo": "akuczala/4d-game",
"path": "/src/gui.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn build_http_endpoint<B, C>(
&self,
tcp_connect: C,
tap_layer: tap::Layer,
metrics: ProxyMetrics,
span_sink: Option<mpsc::Sender<oc::Span>>,
) -> impl svc::NewService<
HttpEndpoint,
Service = impl tower::Service<
http::Reques... | code_fim | hard | {
"lang": "rust",
"repo": "devopstoday11/linkerd2-proxy",
"path": "/linkerd/app/outbound/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: devopstoday11/linkerd2-proxy path: /linkerd/app/outbound/src/lib.rs
ings, rust_2018_idioms)]
use self::allow_discovery::*;
pub use self::endpoint::{HttpConcrete, HttpEndpoint, HttpLogical, LogicalPerRequest, TcpEndpoint};
use futures::future;
use linkerd2_app_core::{
classify,
config::{... | code_fim | hard | {
"lang": "rust",
"repo": "devopstoday11/linkerd2-proxy",
"path": "/linkerd/app/outbound/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: devopstoday11/linkerd2-proxy path: /linkerd/app/outbound/src/lib.rs
),
Future = impl Unpin + Send + 'static,
Error = impl Into<Error>,
> + Unpin
+ Send
+ 'static,
> + Clone
+ Unpin
+ Send
... | code_fim | hard | {
"lang": "rust",
"repo": "devopstoday11/linkerd2-proxy",
"path": "/linkerd/app/outbound/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let request = build_request(Method::POST, TestFile::EMPTY)?;
let got = h.handle_request(&request);
assert_eq!(got.status(), StatusCode::METHOD_NOT_ALLOWED);
let request = build_request(Method::PUT, TestFile::EMPTY)?;
let got = h.handle_request(&request);
as... | code_fim | hard | {
"lang": "rust",
"repo": "etandel/isner",
"path": "/src/file_handler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: etandel/isner path: /src/file_handler.rs
use std::fs::File;
use std::io::Read;
use std::path::PathBuf;
use log::debug;
use http::status::StatusCode;
use http::Method;
use super::http_handler::{Handler, Response};
use super::parser::Request;
pub struct FileHandler {
root_dir: PathBuf,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "etandel/isner",
"path": "/src/file_handler.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (FlatMapConsumer::new(self.base.split_off(), self.map_op),
FlatMapConsumer::new(self.base.split_off(), self.map_op),
self.base.to_reducer())
}
fn into_folder(self) -> Self::Folder {
FlatMapFolder {
base: self.base,
map_op: self.map_op,
... | code_fim | hard | {
"lang": "rust",
"repo": "bluss/rayon",
"path": "/src/par_iter/flat_map.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bluss/rayon path: /src/par_iter/flat_map.rs
use super::*;
use super::internal::*;
use std::f64;
pub struct FlatMap<M, MAP_OP> {
base: M,
map_op: MAP_OP,
}
impl<M, MAP_OP> FlatMap<M, MAP_OP> {
pub fn new(base: M, map_op: MAP_OP) -> FlatMap<M, MAP_OP> {
FlatMap { base: base, ... | code_fim | hard | {
"lang": "rust",
"repo": "bluss/rayon",
"path": "/src/par_iter/flat_map.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> FlatMapFolder {
base: self.base,
map_op: self.map_op,
previous: None,
}
}
}
impl<'m, ITEM, MAPPED_ITEM, C, MAP_OP> UnindexedConsumer<ITEM>
for FlatMapConsumer<'m, C, MAP_OP>
where C: UnindexedConsumer<MAPPED_ITEM::Item>,
MAP_OP: Fn... | code_fim | hard | {
"lang": "rust",
"repo": "bluss/rayon",
"path": "/src/par_iter/flat_map.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let client_options = ClientOptions::new();
let client = Client::connect_with_options(&host, port, client_options).expect("Bad client");
if let (Some(username), Some(password)) = (user, pass) {
let auth_db = client.db("admin");
auth_db.... | code_fim | hard | {
"lang": "rust",
"repo": "SebAubin/spotme",
"path": "/src/mongo_connection.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let doc = doc! { "test": 1 };
if let Ok(_) = coll.insert_one(doc, None) {
return Ok(db);
} else {
return Err(Error::Other("Unable to set up client properly".to_string()));
}
}
fn is_valid(&self, conn: &mut Se... | code_fim | hard | {
"lang": "rust",
"repo": "SebAubin/spotme",
"path": "/src/mongo_connection.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SebAubin/spotme path: /src/mongo_connection.rs
const DB_CONNECTION_TIMEOUT_MS: i64 = 5000;
const DATABASE_NAME: &'static str = "spotme";
mod r2d2_mongo {
use r2d2;
use mongodb;
use mongodb::{Client, ThreadedClient};
use mongodb::ClientOptions;
use mongodb::connstring::{self,... | code_fim | hard | {
"lang": "rust",
"repo": "SebAubin/spotme",
"path": "/src/mongo_connection.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Memory task
if CONFIG.memory.enabled {
let b = init_block(tx.clone(), memory::get_memory, CONFIG.memory.delay);
task::spawn(b);
}
// Weather task
if CONFIG.weather.enabled {
let b = init_block(tx.clone(), weather::get_weather, CONFIG.weather.delay);
... | code_fim | hard | {
"lang": "rust",
"repo": "hhacker1999/rsblocks",
"path": "/src/run.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Weather task
if CONFIG.weather.enabled {
let b = init_block(tx.clone(), weather::get_weather, CONFIG.weather.delay);
task::spawn(b);
}
// Battery task
if CONFIG.battery.enabled {
let b = init_block(tx.clone(), battery::get_battery, CONFIG.battery.delay);
... | code_fim | hard | {
"lang": "rust",
"repo": "hhacker1999/rsblocks",
"path": "/src/run.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hhacker1999/rsblocks path: /src/run.rs
use crate::blockmanager::*;
use crate::config::CONFIG;
use crate::types::*;
use crate::utils::*;
use async_std::channel::{unbounded, Sender};
use async_std::task;
use async_std::task::sleep;
use futures::future;
use futures::stream::StreamExt;
use std::futu... | code_fim | hard | {
"lang": "rust",
"repo": "hhacker1999/rsblocks",
"path": "/src/run.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = args.value_of("input").unwrap_or("-");
if input == "-" {
let stdin = io::stdin();
let reader = stdin.lock();
process_lines(reader, re);
} else {
let f = File::open(input).unwrap();
let reader = BufReader::new(f);
process_lines(reader... | code_fim | medium | {
"lang": "rust",
"repo": "behrad-ahmadpour/yum-rust",
"path": "/examples/search_in_file_or_stdin.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: behrad-ahmadpour/yum-rust path: /examples/search_in_file_or_stdin.rs
use clap::{App, Arg};
use regex::Regex;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
// TODO: Add example for Sized application
//
// The stack is fast.
// The heap is slow.
// That differen... | code_fim | hard | {
"lang": "rust",
"repo": "behrad-ahmadpour/yum-rust",
"path": "/examples/search_in_file_or_stdin.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn add(self, rhs: Point3) -> Point3 {
Point3 {
x: self.x + rhs.x,
y: self.y + rhs.y,
z: self.z + rhs.z
}
}
}
impl Sub for Point3 {
type Output = Point3;
fn sub(self, rhs: Point3) -> Point3 {
Point3 {
x: self.x - rhs.x,
y: self.y - rhs.y,
z: self.z - rhs.z
}
}
}<|fim_pre... | code_fim | hard | {
"lang": "rust",
"repo": "nsantorello/raytracer-rs",
"path": "/src/math/point.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn distance_squared(&self, other: &Point3) -> f64 {
let dx = self.x - other.x;
let dy = self.y - other.y;
let dz = self.z - other.z;
return dx * dx + dy * dy + dz * dz;
}
}
impl Add for Point3 {
type Output = Point3;
fn add(self, rhs: Point3) -> Point3 {
Point3 {
x: ... | code_fim | medium | {
"lang": "rust",
"repo": "nsantorello/raytracer-rs",
"path": "/src/math/point.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nsantorello/raytracer-rs path: /src/math/point.rs
#[derive(Debug)]
pub struct Point3 {
pub x: f64,
pub y: f64,
pub z: f64,
}
use std::num::Float;
use std::ops::{Add, Sub};
impl Point3 {
pub fn distance(&self, other: &Point3) -> f64 {
self.distance_squared(other).sqrt()
}
pub... | code_fim | medium | {
"lang": "rust",
"repo": "nsantorello/raytracer-rs",
"path": "/src/math/point.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // We are a match, so fire off to our child instance.
match req.url_mut() {
Some(path) => {
// Insert the unmodified path into the alloy.
match alloy.find::<OriginalUrl>() {
Some(_) => (),
None => alloy.ins... | code_fim | hard | {
"lang": "rust",
"repo": "theptrk/mount",
"path": "/src/mount.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theptrk/mount path: /src/mount.rs
use regex::Regex;
use iron::{Middleware, Request, Response, Alloy, Chain, Status, Continue};
use iron::mixin::GetUrl;
/// Exposes the original, unmodified path to be stored in an Alloy.
pub struct OriginalUrl(pub String);
/// `Mount` is a simple mounting midd... | code_fim | hard | {
"lang": "rust",
"repo": "theptrk/mount",
"path": "/src/mount.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> req: &mut Request,
res: &mut Response,
alloy: &mut Alloy) -> Status {
// This method is ugly, but it is hard to make it pretty
// because we can't both borrow path from inside of request
// while allowing chain.dispatch to borrow it as mutable... | code_fim | hard | {
"lang": "rust",
"repo": "theptrk/mount",
"path": "/src/mount.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LordSentox/samc21n path: /src/osc32kctrl/intenclr.rs
#[doc = "Register `INTENCLR` reader"]
pub struct R(crate::R<INTENCLR_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<INTENCLR_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl Fro... | code_fim | hard | {
"lang": "rust",
"repo": "LordSentox/samc21n",
"path": "/src/osc32kctrl/intenclr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `CLKFAIL` writer - XOSC32K Clock Failure Detector Interrupt Enable"]
pub struct CLKFAIL_W<'a> {
w: &'a mut W,
}
impl<'a> CLKFAIL_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
... | code_fim | hard | {
"lang": "rust",
"repo": "LordSentox/samc21n",
"path": "/src/osc32kctrl/intenclr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
pub extern fn backint() -> c_int {
let a = 1;
a
}<|fim_prefix|>// repo: yanbowen1994/rust_ffi_c_call_rust path: /gcc/src/lib.rs
#![crate_type = "staticlib"]
use std::ptr;
use std::ffi::{CString, CStr};
use std::os::raw::{c_char, c_int};
<|fim_middle|>#[no_mangle]
pub extern fn stat... | code_fim | hard | {
"lang": "rust",
"repo": "yanbowen1994/rust_ffi_c_call_rust",
"path": "/gcc/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yanbowen1994/rust_ffi_c_call_rust path: /gcc/src/lib.rs
#![crate_type = "staticlib"]
use std::ptr;
use std::ffi::{CString, CStr};
use std::os::raw::{c_char, c_int};
<|fim_suffix|>#[no_mangle]
pub extern fn backint() -> c_int {
let a = 1;
a
}<|fim_middle|>#[no_mangle]
pub extern fn stat... | code_fim | hard | {
"lang": "rust",
"repo": "yanbowen1994/rust_ffi_c_call_rust",
"path": "/gcc/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[rstest]
#[tokio::test]
async fn recursive() {
let h = harness(&[
"mypool/brother",
"mypool/brother/nephew",
"mypool/sister",
"mypool/sister/niece",
]);
bfffs()
.arg("--sock")
.arg(h.sockpath.as_os_str())
.args(["fs", "list", "-r", "mypo... | code_fim | hard | {
"lang": "rust",
"repo": "bfffs/bfffs",
"path": "/bfffs/tests/integration/bfffs/fs/list.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bfffs/bfffs path: /bfffs/tests/integration/bfffs/fs/list.rs
use std::{
fs,
os::unix::fs::FileTypeExt,
path::PathBuf,
process::Command,
time::Duration,
};
use assert_cmd::{cargo::cargo_bin, prelude::*};
use rstest::rstest;
use tempfile::{Builder, TempDir};
use super::super::... | code_fim | hard | {
"lang": "rust",
"repo": "bfffs/bfffs",
"path": "/bfffs/tests/integration/bfffs/fs/list.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> macro_rules! three_of_a_kind {
() => {
Hand::ThreeOfAKind(
Value::Two,
[
card!("AS"),
card!("KD"),
card!("2C"),
card!("2H"),
card!("2S"),
... | code_fim | hard | {
"lang": "rust",
"repo": "ocstl/project_euler",
"path": "/src/cards/poker.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ocstl/project_euler path: /src/cards/poker.rs
use super::playing_cards::{Card, Value};
type FiveCards = [Card; 5];
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq)]
// Add values at the beginning to implement PartialOrd and Ord easily.
pub enum Hand {
HighCard(FiveCards),
OnePair(Value,... | code_fim | hard | {
"lang": "rust",
"repo": "ocstl/project_euler",
"path": "/src/cards/poker.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(flush!() > straight!());
assert!(flush!() > three_of_a_kind!());
assert!(flush!() > two_pairs!());
assert!(flush!() > one_pair!());
assert!(flush!() > high_card!());
}
#[test]
fn test_straight() {
let actual = hand!(["2D", "3D", "4D", "5... | code_fim | hard | {
"lang": "rust",
"repo": "ocstl/project_euler",
"path": "/src/cards/poker.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (id, rem) = u8::from_bytes(bytes)?;
match AccessRights::from_bits(id) {
Some(rights) => Ok((rights, rem)),
None => Err(bytesrepr::Error::Formatting),
}
}
}
impl Serialize for AccessRights {
fn serialize<S: Serializer>(&self, serializer: S) -> Re... | code_fim | hard | {
"lang": "rust",
"repo": "nguyenminhhieu12041996/casper-node",
"path": "/types/src/access_rights.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> test_writable(AccessRights::WRITE, true);
test_writable(AccessRights::READ_WRITE, true);
test_writable(AccessRights::ADD_WRITE, true);
test_writable(AccessRights::READ, false);
test_writable(AccessRights::ADD, false);
test_writable(AccessRights::READ_ADD, fa... | code_fim | hard | {
"lang": "rust",
"repo": "nguyenminhhieu12041996/casper-node",
"path": "/types/src/access_rights.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nguyenminhhieu12041996/casper-node path: /types/src/access_rights.rs
use alloc::vec::Vec;
use bitflags::bitflags;
use datasize::DataSize;
use rand::{
distributions::{Distribution, Standard},
Rng,
};
use serde::{de::Error as SerdeError, Deserialize, Deserializer, Serialize, Serializer};
... | code_fim | hard | {
"lang": "rust",
"repo": "nguyenminhhieu12041996/casper-node",
"path": "/types/src/access_rights.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let c = encrypt(msg, pub_key);
let (aa, bb) = decrypt(c, pri_key, n, h);
println!("Original A Bits : {:?}", a.all_set_bits());
println!("Decrypted A Bits: {:?}", aa.all_set_bits());
println!("Original B Bits : {:?}", b.all_set_bits());
println!("Decrypted B Bits: {:?}", bb.all_set... | code_fim | medium | {
"lang": "rust",
"repo": "thenaesh/mersenne-pkc",
"path": "/src/bin/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let alice_session_key = extract_128_bit_key(&(a,b));
let bob_session_key = extract_128_bit_key(&(aa, bb));
println!("Alice\'s Session Key : {}", alice_session_key);
println!("Bob\'s Session Key : {}", bob_session_key);
}<|fim_prefix|>// repo: thenaesh/mersenne-pkc path: /src/bin/main.r... | code_fim | hard | {
"lang": "rust",
"repo": "thenaesh/mersenne-pkc",
"path": "/src/bin/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thenaesh/mersenne-pkc path: /src/bin/main.rs
use mersennepkc::*;
fn main() {
let n = 86243;
let h = 128;
let (f, g) = randomly_generate_message(n, h);
let mut pub_key = f.clone();
pub_key /= &g;
let pri_key = (f, g);
let msg = randomly_generate_message(n, h);
... | code_fim | hard | {
"lang": "rust",
"repo": "thenaesh/mersenne-pkc",
"path": "/src/bin/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RichoDemus/advent-of-code-2019 path: /src/five.rs
use std::cmp;
use crate::read_lines::read_lines;
pub fn five() {
let mut input = read_lines("five");
let result = exec_with_input(input.pop().unwrap().as_str(), vec![1]);
println!("{:?}", result);
}
fn exec_with_input(intcode: &str... | code_fim | hard | {
"lang": "rust",
"repo": "RichoDemus/advent-of-code-2019",
"path": "/src/five.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if mode == 0 {
self.memory.get(index).expect("could not get value from memory").clone()
} else {
index as i32
}
}
fn write(&mut self, position: usize, value: i32) {
let old = std::mem::replace(&mut self.memory[position], value);
prin... | code_fim | hard | {
"lang": "rust",
"repo": "RichoDemus/advent-of-code-2019",
"path": "/src/five.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chrismolli/msp430fr6972 path: /src/port_5_6/p5in.rs
#[doc = "Register `P5IN` reader"]
pub struct R(crate::R<P5IN_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<P5IN_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl core::convert::F... | code_fim | hard | {
"lang": "rust",
"repo": "chrismolli/msp430fr6972",
"path": "/src/port_5_6/p5in.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `P5IN6` writer - P5IN6"]
pub struct P5IN6_W<'a> {
w: &'a mut W,
}
impl<'a> P5IN6_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inlin... | code_fim | hard | {
"lang": "rust",
"repo": "chrismolli/msp430fr6972",
"path": "/src/port_5_6/p5in.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc214/src/bin/a.rs
use proconio::input;
fn main() {
input! {
n: usiz<|fim_suffix|>n <= 211 {
6
} else if n <= 214 {
8
} else {
unreachable!()
};
println!("{}", ans);
}<|fim_middle|>e,
};
... | code_fim | medium | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/abc214/src/bin/a.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Y-Nak/menoh-rs path: /src/error.rs
//! This module defines Error and Result type of Menoh
use std::error;
use std::ffi::CStr;
use std::fmt;
use ffi;
use ffi::menoh_get_last_error_message;
#[derive(Debug)]
pub enum Error {
// C-API Defined error
StdError,
UnknownError,
InvalidF... | code_fim | hard | {
"lang": "rust",
"repo": "Y-Nak/menoh-rs",
"path": "/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: embed-rs/embedded_stm32f7 path: /src/usart.rs
doc = "Bit 9 - Parity selection" ]
pub fn ps(&self) -> bool {
self.bits.get_bit(9u8)
}
# [ doc = "Bit 8 - PE interrupt enable" ]
pub fn peie(&self) -> bool {
self.bits.get_bit(8u8)
}
# [ doc = "Bit 7 - interru... | code_fim | hard | {
"lang": "rust",
"repo": "embed-rs/embedded_stm32f7",
"path": "/src/usart.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: embed-rs/embedded_stm32f7 path: /src/usart.rs
ol {
self.bits.get_bit(10u8)
}
# [ doc = "Bit 9 - Parity selection" ]
pub fn ps(&self) -> bool {
self.bits.get_bit(9u8)
}
# [ doc = "Bit 8 - PE interrupt enable" ]
pub fn peie(&self) -> bool {
self.bits... | code_fim | hard | {
"lang": "rust",
"repo": "embed-rs/embedded_stm32f7",
"path": "/src/usart.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Brr {
# [ doc = "Bits 4:15 - DIV_Mantissa" ]
pub fn set_div_mantissa(&mut self, value: u16) {
self.bits.set_range(4u8..16u8, value as u32);
}
# [ doc = "Bits 0:3 - DIV_Fraction" ]
pub fn set_div_fraction(&mut self, value: u8) {
self.bits.set_range(0u8..4u8, value a... | code_fim | hard | {
"lang": "rust",
"repo": "embed-rs/embedded_stm32f7",
"path": "/src/usart.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let term = Term::stdout();
let mut max_x = 0;
let mut max_y = 0;
term.clear_screen();
for (location, &cell) in map.iter() {
term.move_cursor_to(location.1, location.0);
max_x = std::cmp::max(max_x, location.1);
max_y = std::cmp::max(max_y, location.0);
t... | code_fim | hard | {
"lang": "rust",
"repo": "kenrick95/adventofcode2019",
"path": "/src/day19.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kenrick95/adventofcode2019 path: /src/day19.rs
use super::program::*;
use console::Term;
use std::cell::RefCell;
use std::collections::HashMap;
pub fn main() {
let positions = super::utils::get_list_of_numbers_from_file::<i128>("./src/day19-real.log");
part1(&positions);
// part2(&p... | code_fim | hard | {
"lang": "rust",
"repo": "kenrick95/adventofcode2019",
"path": "/src/day19.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print_map(&map);
println!("Answer part 1: {:?}", answer);
}
fn print_map(map: &HashMap<(usize, usize), bool>) {
let term = Term::stdout();
let mut max_x = 0;
let mut max_y = 0;
term.clear_screen();
for (location, &cell) in map.iter() {
term.move_cursor_to(location.1, l... | code_fim | hard | {
"lang": "rust",
"repo": "kenrick95/adventofcode2019",
"path": "/src/day19.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: linebender/piet path: /piet-common/src/cg_back.rs
// allows e.g. raw_data[dst_off + x * 4 + 2] = buf[src_off + x * 4 + 0];
#![allow(clippy::identity_op)]
//! Support for piet CoreGraphics back-end.
use std::marker::PhantomData;
use std::path::Path;
#[cfg(feature = "png")]
use std::{fs::File, i... | code_fim | hard | {
"lang": "rust",
"repo": "linebender/piet",
"path": "/piet-common/src/cg_back.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// The associated text layout type for this backend.
///
/// This type matches `RenderContext::Text::TextLayout`
pub type PietTextLayout = CoreGraphicsTextLayout;
/// The associated text layout builder for this backend.
///
/// This type matches `RenderContext::Text::TextLayoutBuilder`
pub type PietText... | code_fim | hard | {
"lang": "rust",
"repo": "linebender/piet",
"path": "/piet-common/src/cg_back.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: heinrich5991/libtw2 path: /common/src/str.rs
use arrayvec::Array;
use arrayvec::ArrayString;
pub fn truncated_arraystring<A: Array<Item=u8> + Copy>(mut s: &str)
-> ArrayString<A>
{
let mut result = ArrayString::new();
if s.len() > result.capacity() {
for n in (0..result.capa... | code_fim | hard | {
"lang": "rust",
"repo": "heinrich5991/libtw2",
"path": "/common/src/str.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> truncated_arraystring::<[u8; 2]>(&v);
true
}
fn truncated_arraystring4(v: String) -> bool {
truncated_arraystring::<[u8; 4]>(&v);
true
}
fn truncated_arraystring8(v: String) -> bool {
truncated_arraystring::<[u8; 8... | code_fim | hard | {
"lang": "rust",
"repo": "heinrich5991/libtw2",
"path": "/common/src/str.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> truncated_arraystring::<[u8; 8]>(&v);
true
}
fn truncated_arraystring16(v: String) -> bool {
truncated_arraystring::<[u8; 16]>(&v);
true
}
}
}<|fim_prefix|>// repo: heinrich5991/libtw2 path: /common/src/str.rs
use arrayvec::Array... | code_fim | hard | {
"lang": "rust",
"repo": "heinrich5991/libtw2",
"path": "/common/src/str.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.tape.len() <= self.head + 1 {
self.head = self.head + 1;
self.tape.push(e.index_symbol(ASTSym::Blank));
} else {
self.head = self.head + 1;
}
}
fn print(&mut self, u: usize) {
self.tape[self.head] = u;
}
fn update(... | code_fim | hard | {
"lang": "rust",
"repo": "heyrutvik/turing-script-rs",
"path": "/src/interpreter.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: heyrutvik/turing-script-rs path: /src/interpreter.rs
use crate::compiler::Env;
use crate::core::ast::Sym as ASTSym;
use crate::core::standard::{Op, Sym};
pub fn eval(e: &Env, steps: u32) -> Vec<String> {
_eval(steps, e, &mut CompleteConfig::new(e))
}
<|fim_suffix|>impl CompleteConfig {
... | code_fim | hard | {
"lang": "rust",
"repo": "heyrutvik/turing-script-rs",
"path": "/src/interpreter.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.tape
.iter()
.map(|&s| match ss[s].clone() {
ASTSym::String(s) => s,
ASTSym::Blank => "_".to_string(),
_ => unreachable!(),
})
.collect::<Vec<String>>()
}
fn add_square(&mut self, e: &Env) ... | code_fim | hard | {
"lang": "rust",
"repo": "heyrutvik/turing-script-rs",
"path": "/src/interpreter.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brendanrbrown/extendr path: /extendr-macros/src/extendr_module.rs
use crate::wrappers;
use proc_macro::TokenStream;
use quote::{format_ident, quote};
use syn::{parse::ParseStream, parse_macro_input, Ident, Token, Type};
pub fn extendr_module(item: TokenStream) -> TokenStream {
let module = ... | code_fim | hard | {
"lang": "rust",
"repo": "brendanrbrown/extendr",
"path": "/extendr-macros/src/extendr_module.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[no_mangle]
#[allow(non_snake_case)]
pub extern "C" fn #wrap_make_module_wrappers(
use_symbols_sexp: extendr_api::SEXP,
package_name_sexp: extendr_api::SEXP,
) -> extendr_api::SEXP {
unsafe {
use extendr_api::robj::*;
... | code_fim | hard | {
"lang": "rust",
"repo": "brendanrbrown/extendr",
"path": "/extendr-macros/src/extendr_module.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use syn::spanned::Spanned;
let mut res = Self {
modname: None,
fnnames: Vec::new(),
implnames: Vec::new(),
usenames: Vec::new(),
};
while !input.is_empty() {
if let Ok(kmod) = input.parse::<Token![mod]>() {
... | code_fim | hard | {
"lang": "rust",
"repo": "brendanrbrown/extendr",
"path": "/extendr-macros/src/extendr_module.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> db.context().opaque_struct_type(&name)
}
/// Constructs the `TypeInfo` for the specified HIR type
pub fn type_info_query(db: &dyn IrDatabase, ty: Ty) -> TypeInfo {
let target = db.target_data();
match ty {
Ty::Apply(ctor) => match ctor.ctor {
TypeCtor::Float(ty) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "zeyonaut/mun",
"path": "/crates/mun_codegen/src/ir/ty.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let context = db.context();
match ity.bitness.resolve(&db.target_data_layout()) {
IntBitness::X128 => context.i128_type(),
IntBitness::X64 => context.i64_type(),
IntBitness::X32 => context.i32_type(),
IntBitness::X16 => context.i16_type(),
IntBitness::X8 => ... | code_fim | hard | {
"lang": "rust",
"repo": "zeyonaut/mun",
"path": "/crates/mun_codegen/src/ir/ty.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zeyonaut/mun path: /crates/mun_codegen/src/ir/ty.rs
use super::try_convert_any_to_basic;
use crate::{
type_info::{TypeInfo, TypeSize},
CodeGenParams, IrDatabase,
};
use hir::{
ApplicationTy, CallableDef, FloatBitness, FloatTy, IntBitness, IntTy, ResolveBitness, Ty,
TypeCtor,
};
u... | code_fim | hard | {
"lang": "rust",
"repo": "zeyonaut/mun",
"path": "/crates/mun_codegen/src/ir/ty.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> where S: Serializer
{
(self.x, self.y, self.w, self.h, self.ox, self.oy).serialize(serializer)
}
}
impl<'de> Deserialize<'de> for SpriteBounds {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>
{
Deserialize::deseriali... | code_fim | medium | {
"lang": "rust",
"repo": "lasagnaphil/gengine-rs",
"path": "/src/sprite.rs",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lasagnaphil/gengine-rs path: /src/sprite.rs
use serde::ser::{Serialize, Serializer};
use serde::de::{Deserialize, Deserializer};
use storage::ResourceID;
use texture::Texture;
pub struct SpriteBounds {
x: u32, y: u32,
w: u32, h: u32,
ox: u32, oy: u32
}
impl SpriteBounds {
pub f... | code_fim | medium | {
"lang": "rust",
"repo": "lasagnaphil/gengine-rs",
"path": "/src/sprite.rs",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> //fn view_mut(&self, source: &mut Self::Source) -> &mut Self::Target;
}<|fim_prefix|>// repo: Frando/VIZIA path: /src/binding/lens.rs
pub trait Lens: Clone {
type Source;
type Target;
<|fim_middle|> fn view<'a>(&self, source: &'a Self::Source) -> &'a Self::Target;
| code_fim | medium | {
"lang": "rust",
"repo": "Frando/VIZIA",
"path": "/src/binding/lens.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Frando/VIZIA path: /src/binding/lens.rs
pub trait Lens: Clone {
type Source;
type Target;
<|fim_suffix|> //fn view_mut(&self, source: &mut Self::Source) -> &mut Self::Target;
}<|fim_middle|> fn view<'a>(&self, source: &'a Self::Source) -> &'a Self::Target;
| code_fim | medium | {
"lang": "rust",
"repo": "Frando/VIZIA",
"path": "/src/binding/lens.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stanley-fork/variant-go-server path: /client/src/agents/mod.rs
pub mod game_store;
pub use self::game_store::{GameStore, GameStoreState};
p<|fim_suffix|>d_store::{BoardStore, BoardStoreState};<|fim_middle|>ub mod board_store;
pub use self::boar | code_fim | easy | {
"lang": "rust",
"repo": "stanley-fork/variant-go-server",
"path": "/client/src/agents/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>d_store::{BoardStore, BoardStoreState};<|fim_prefix|>// repo: stanley-fork/variant-go-server path: /client/src/agents/mod.rs
pub mod game_store;
pub use self::game_store::{GameStore, GameStoreState};
p<|fim_middle|>ub mod board_store;
pub use self::boar | code_fim | easy | {
"lang": "rust",
"repo": "stanley-fork/variant-go-server",
"path": "/client/src/agents/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: humenda/muk path: /src/main.rs
#![no_std]
#![no_main]
#![feature(lang_items)]
mod io;
mod thread;
mod types;
use core::fmt::Write;
use crate::io::console;
<|fim_suffix|>#[panic_handler]
fn panic(info: &core::panic::PanicInfo) -> ! {
let mut log = console::Log::new();
writeln!(log, "{}... | code_fim | medium | {
"lang": "rust",
"repo": "humenda/muk",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>extern "C" {
static first_stack: usize;
}
// C function that the assembly file jumps to
#[no_mangle] // ensure that this symbol is called `main` in the output
pub extern "C" fn boot() {
let mut log = console::Log::new();
writeln!(log, "Rust for mu kernels! :)").unwrap();
unsafe {
w... | code_fim | medium | {
"lang": "rust",
"repo": "humenda/muk",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jj-marinho/sierpinski-rustpy path: /src/main.rs
use rand::Rng;
use serde::Serialize;
use std::fs::OpenOptions;
use std::io::prelude::*;
use std::io::stdout;
#[derive(Serialize)]
struct Points<'a>(&'a [f64], &'a [f64]);
fn main() {
let number_of_points = input("How many points? ").parse::<u... | code_fim | medium | {
"lang": "rust",
"repo": "jj-marinho/sierpinski-rustpy",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// input mimics python input function
pub fn input(msg: &str) -> String {
print!("{}", msg);
stdout().flush().unwrap();
let mut s = String::new();
let _ = std::io::stdin().read_line(&mut s).unwrap();
s.strip_suffix("\n").unwrap().to_string()
}<|fim_prefix|>// repo: jj-marinho/sierpin... | code_fim | hard | {
"lang": "rust",
"repo": "jj-marinho/sierpinski-rustpy",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconssharp/social/icon_precision_manufacturing.rs
pub struct IconPrecisionManufacturing {
props: crate::Props,
}
impl yew::Component for IconPrecisionManufacturing {
type Properties = crate::Props;
type Message = ();
fn create(pr... | code_fim | hard | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialiconssharp/social/icon_precision_manufacturing.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chenguzhen87/deno path: /ops/op2/dispatch_slow.rs
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use super::generator_state::GeneratorState;
use super::signature::Arg;
use super::signature::NumericArg;
use super::signature::ParsedSignature;
use super::signature::RetVa... | code_fim | hard | {
"lang": "rust",
"repo": "chenguzhen87/deno",
"path": "/ops/op2/dispatch_slow.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let GeneratorState {
deno_core,
opctx,
fn_args,
needs_args,
..
} = generator_state;
*needs_args = true;
quote!(let #opctx = unsafe {
&*(#deno_core::v8::Local::<#deno_core::v8::External>::cast(#fn_args.data()).value()
as *const #deno_core::_ops::OpCtx)
};)
}
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "chenguzhen87/deno",
"path": "/ops/op2/dispatch_slow.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tokens = quote!(
match #result {
Ok(#result) => {
#infallible
}
Err(err) => {
#exception
}
};
);
Ok(tokens)
}
/// Generates code to throw an exception, adding required additional dependencies as needed.
fn throw_exception(
generator_state: &mut ... | code_fim | hard | {
"lang": "rust",
"repo": "chenguzhen87/deno",
"path": "/ops/op2/dispatch_slow.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline(always)]
fn position(&self) -> Self::Position {
self.as_bytes().position()
}
}
impl<'a> StreamOnce for &'a str {
type Item = char;
type Range = &'a str;
#[inline]
fn uncons(&mut self) -> Result<char, Error<char, &'a str>> {
let mut chars = self.chars(... | code_fim | hard | {
"lang": "rust",
"repo": "parsonsmatt/combine",
"path": "/src/primitives.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: parsonsmatt/combine path: /src/primitives.rs
eStream` which is capable of providing it's entire range.
pub trait FullRangeStream: RangeStream {
/// Returns the entire range of `self`
fn range(&self) -> Self::Range;
}
/// Removes items from the input while `predicate` returns `true`.
#[i... | code_fim | hard | {
"lang": "rust",
"repo": "parsonsmatt/combine",
"path": "/src/primitives.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: parsonsmatt/combine path: /src/primitives.rs
}
}
}
pub struct ReadStream<R> {
bytes: Bytes<R>,
}
impl<R: Read> StreamOnce for ReadStream<R> {
type Item = u8;
type Range = u8;
#[inline]
fn uncons(&mut self) -> Result<u8, Error<u8, u8>> {
match self.byte... | code_fim | hard | {
"lang": "rust",
"repo": "parsonsmatt/combine",
"path": "/src/primitives.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kgalang/fantasyrustball path: /src/handlers/leagues.rs
use crate::database::PoolType;
use crate::errors::ApiError;
use crate::helpers::{respond_json, respond_ok};
use crate::managers::leagues::{create, delete, find_with_details, get_all_details, update};
use crate::models::leagues::{
CreateL... | code_fim | hard | {
"lang": "rust",
"repo": "kgalang/fantasyrustball",
"path": "/src/handlers/leagues.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let league = block(move || update(&pool, &update_league, &update_ruleset)).await?;
respond_json(league)
}
pub async fn delete_league(
league_id: Path<Uuid>,
pool: Data<PoolType>,
) -> Result<HttpResponse, ApiError> {
block(move || delete(&pool, *league_id)).await?;
respond_ok()
}
... | code_fim | hard | {
"lang": "rust",
"repo": "kgalang/fantasyrustball",
"path": "/src/handlers/leagues.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn update_league(
league_id: Path<Uuid>,
pool: Data<PoolType>,
params: Json<UpdateLeagueRequest>,
) -> Result<Json<LeagueDetails>, ApiError> {
let date_time_str = [params.start.clone(), " 00:00:00".to_string()].concat();
let league_start = NaiveDateTime::parse_from_str(&date_... | code_fim | hard | {
"lang": "rust",
"repo": "kgalang/fantasyrustball",
"path": "/src/handlers/leagues.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// TODO: make transaction states extendable, like:
// Core(Init) and Custom(XMySmtpState) / Custom("X-MY-SMTP-STATE")
/// Represents the current state of an SMTP transaction.
///
/// This is useful for checking if an incoming SMTP command is allowed at any given moment
/// during an SMTP transaction.
#[d... | code_fim | medium | {
"lang": "rust",
"repo": "minioin/rustastic-smtp",
"path": "/src/common/transaction.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.