text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: DiamondLovesYou/rust-vpx path: /src/lib/lib.rs
use std::borrow::Cow;
use std::ffi::{CStr};
use std::mem::transmute;
extern crate vpx_sys as ffi;
extern crate libc;
pub mod encoder;
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
pub enum Error {
Generic(u32),
Mem,
AbiMismatch,
In... | code_fim | hard | {
"lang": "rust",
"repo": "DiamondLovesYou/rust-vpx",
"path": "/src/lib/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
ColorSpace::BT601 => ffi::VPX_CS_BT_601,
ColorSpace::BT709 => ffi::VPX_CS_BT_709,
ColorSpace::SMPTE170 => ffi::VPX_CS_SMPTE_170,
ColorSpace::SMPTE240 => ffi::VPX_CS_SMPTE_240,
ColorSpace::BT2020 => ffi::VPX_CS_BT_2020,
... | code_fim | hard | {
"lang": "rust",
"repo": "DiamondLovesYou/rust-vpx",
"path": "/src/lib/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/meteora path: /meteora/src/cli/delete.rs
use clap::ArgMatches;
use meteora_client::kv::client::KVClient;
use crate::log::set_logger;
<|fim_suffix|> let server = matches.value_of("SERVER").unwrap();
let key = matches.value_of("KEY").unwrap();
let mut kv_client = KVClient::n... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/meteora",
"path": "/meteora/src/cli/delete.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let server = matches.value_of("SERVER").unwrap();
let key = matches.value_of("KEY").unwrap();
let mut kv_client = KVClient::new(server);
kv_client.delete(key.to_string())
}<|fim_prefix|>// repo: isgasho/meteora path: /meteora/src/cli/delete.rs
use clap::ArgMatches;
use meteora_client::... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/meteora",
"path": "/meteora/src/cli/delete.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cstorey/weft path: /weft/src/template.rs
use std::{borrow::Cow, io};
use v_htmlescape::escape;
/// An internal representation of a qualified name, such as a tag or attribute.
/// Does not currently support namespaces.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct QName<'a>... | code_fim | hard | {
"lang": "rust",
"repo": "cstorey/weft",
"path": "/weft/src/template.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for attr in attrs {
// TODO: Escaping!
self.0.write_all(b" ")?;
self.0.write_all(attr.name.as_bytes())?;
self.0.write_all(b"=")?;
write!(self.0, "\"{}\"", escape(&attr.value))?;
}
self.0.write_all(b">")?;
Ok(())
... | code_fim | hard | {
"lang": "rust",
"repo": "cstorey/weft",
"path": "/weft/src/template.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// An attribute name and value pair.
#[derive(Debug)]
pub struct AttrPair<'n, 'v> {
name: QName<'n>,
value: Cow<'v, str>,
}
/// Something that we can use to actually render HTML to text.
///
pub trait RenderTarget {
/// Open an element with the given name and attributes.
fn start_element... | code_fim | hard | {
"lang": "rust",
"repo": "cstorey/weft",
"path": "/weft/src/template.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PortalNetwork/graph-node path: /graphql/src/query/ast.rs
use graphql_parser::query::*;
use std::collections::HashMap;
use graph::prelude::QueryExecutionError;
/// Returns the operation for the given name (or the only operation if no name is defined).
pub fn get_operation<'a>(
document: &'a... | code_fim | hard | {
"lang": "rust",
"repo": "PortalNetwork/graph-node",
"path": "/graphql/src/query/ast.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Returns the response key of a field, which is either its name or its alias (if there is one).
pub fn get_response_key(field: &Field) -> &Name {
field.alias.as_ref().unwrap_or(&field.name)
}
/// Returns up the fragment with the given name, if it exists.
pub fn get_fragment<'a>(document: &'a Docume... | code_fim | hard | {
"lang": "rust",
"repo": "PortalNetwork/graph-node",
"path": "/graphql/src/query/ast.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmgolembiowski/RustyKitchen path: /Experimenting/file_system/src/find_pngs.rs
extern crate glob;
use glob::glob;
<|fim_suffix|> for entry in glob("**/*.png")? {
println!("{}", entry?.display());
}
Ok(())
}<|fim_middle|>fn run() -> Result<()> {
| code_fim | easy | {
"lang": "rust",
"repo": "dmgolembiowski/RustyKitchen",
"path": "/Experimenting/file_system/src/find_pngs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn run() -> Result<()> {
for entry in glob("**/*.png")? {
println!("{}", entry?.display());
}
Ok(())
}<|fim_prefix|>// repo: dmgolembiowski/RustyKitchen path: /Experimenting/file_system/src/find_pngs.rs
extern crate glob;
<|fim_middle|>use glob::glob;
| code_fim | easy | {
"lang": "rust",
"repo": "dmgolembiowski/RustyKitchen",
"path": "/Experimenting/file_system/src/find_pngs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Disasm/stm32l0xx-hal path: /src/exti.rs
//! External interrupt controller
use crate::bb;
use crate::gpio;
use crate::pac::{self, EXTI};
use crate::pwr::PowerMode;
use crate::syscfg::SYSCFG;
use cortex_m::{interrupt, peripheral::NVIC};
pub enum Interrupt {
exti0_1,
exti2_3,
exti4_15... | code_fim | hard | {
"lang": "rust",
"repo": "Disasm/stm32l0xx-hal",
"path": "/src/exti.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn clear_irq(&self, line: u8) {
assert!(line <= 22);
assert_ne!(line, 18);
self.pr.modify(|_, w| unsafe { w.bits(0b1 << line) });
}
/// Enters a low-power mode until an interrupt occurs
///
/// Please note that this method will return after _any_ interrupt tha... | code_fim | hard | {
"lang": "rust",
"repo": "Disasm/stm32l0xx-hal",
"path": "/src/exti.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
}
}
}
#[allow(unused_variables)]
impl From<requests::PayRequest> for pb::PayRequest {
fn from(c: requests::PayRequest) -> Self {
Self {
bolt11: c.bolt11, // Rule #2 for type string
amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for ... | code_fim | hard | {
"lang": "rust",
"repo": "ElementsProject/lightning",
"path": "/cln-grpc/src/convert.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ElementsProject/lightning path: /cln-grpc/src/convert.rs
s)]
impl From<responses::ListpeersPeersChannelsHtlcs> for pb::ListpeersPeersChannelsHtlcs {
fn from(c: responses::ListpeersPeersChannelsHtlcs) -> Self {
Self {
direction: c.direction as i32,
id: c.id, //... | code_fim | hard | {
"lang": "rust",
"repo": "ElementsProject/lightning",
"path": "/cln-grpc/src/convert.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ElementsProject/lightning path: /cln-grpc/src/convert.rs
message: c.message, // Rule #2 for type string
zbase: c.zbase, // Rule #2 for type string
pubkey: c.pubkey.map(|v| v.serialize().to_vec()), // Rule #2 for type pubkey?
}
}
}
#[allow(unused_vari... | code_fim | hard | {
"lang": "rust",
"repo": "ElementsProject/lightning",
"path": "/cln-grpc/src/convert.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Arc::clone(&STRIPE_MOCK_PROCESS)
}
fn teardown() {
// Lock the global to prevent `setup` from attempting to initialize it
let mut deinit = STRIPE_MOCK_PROCESS.lock().unwrap(/* poison */);
// Stop the mock process if the static pointer is the last pointer
if Arc::strong_count(&STRIPE_... | code_fim | hard | {
"lang": "rust",
"repo": "wyyerd/stripe-rs",
"path": "/tests/mock/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wyyerd/stripe-rs path: /tests/mock/mod.rs
//! Setup and teardown for the stripe mock service.
use lazy_static::lazy_static;
use std::process::{Child, Command};
use std::sync::{Arc, Mutex};
lazy_static! {
static ref STRIPE_MOCK_PROCESS: Arc<Mutex<Option<Child>>> = Arc::new(Mutex::new(None))... | code_fim | hard | {
"lang": "rust",
"repo": "wyyerd/stripe-rs",
"path": "/tests/mock/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elertan/shaku path: /shaku/tests/multithread.rs
#![allow(clippy::blacklisted_name, clippy::mutex_atomic)]
use rand::Rng;
use shaku::{module, Component, HasComponent, Interface};
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
trait Foo: Interface {
fn get_value(&self... | code_fim | hard | {
"lang": "rust",
"repo": "elertan/shaku",
"path": "/shaku/tests/multithread.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..NB_THREADS {
let (shared_module, latest_data) = (shared_module.clone(), latest_data.clone()); // local clones to be moved into the thread
handles.push(
thread::Builder::new()
.name(format!("reader #{}", &i))
.spawn(move || {
... | code_fim | hard | {
"lang": "rust",
"repo": "elertan/shaku",
"path": "/shaku/tests/multithread.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: philphilphil/adventofcode path: /2022/src/base.rs
use std::fs;
pub trait Problem {
fn part_one(&self, problem_data: &ProblemData) -> String;
fn part_two(&self, problem_data: &ProblemData) -> String;
}
#[derive(Debug)]
pub struct ProblemData {
pub input: String,
pub p1_result: S... | code_fim | hard | {
"lang": "rust",
"repo": "philphilphil/adventofcode",
"path": "/2022/src/base.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> path
}
pub fn get_answers(day_number: u8, example: bool) -> (String, String) {
let mut path = get_day_base_path(day_number);
path.push_str("_answers");
let answers = fs::read_to_string(path).expect("Unable to read file");
let mut answers = answers.lines();
let (p1_line, p2_line) ... | code_fim | hard | {
"lang": "rust",
"repo": "philphilphil/adventofcode",
"path": "/2022/src/base.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dalais/rocket-hello path: /src/posts/mod.rs
#![allow(proc_macro_derive_resolution_fallback)]
use super::schema::posts;
<|fim_suffix|>#[derive(Queryable, AsChangeset, Serialize, Deserialize)]
#[table_name = "posts"]
pub struct Post {
pub id: i32,
pub title: String,
pub body: String,
... | code_fim | easy | {
"lang": "rust",
"repo": "dalais/rocket-hello",
"path": "/src/posts/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Queryable, AsChangeset, Serialize, Deserialize)]
#[table_name = "posts"]
pub struct Post {
pub id: i32,
pub title: String,
pub body: String,
pub published: bool,
}<|fim_prefix|>// repo: dalais/rocket-hello path: /src/posts/mod.rs
#![allow(proc_macro_derive_resolution_fallback)]
u... | code_fim | easy | {
"lang": "rust",
"repo": "dalais/rocket-hello",
"path": "/src/posts/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Obstacle{
pub fn new(pos: Point2<f32>, radius: f32) -> Self {
Obstacle{
pos: pos,
radius: radius,
is_alive: true
}
}
pub fn update(&mut self) {
todo!()
}
pub fn draw(&mut self, ctx: &mut Context, assets: &Assets)... | code_fim | hard | {
"lang": "rust",
"repo": "Ivaylogi98/boids_rust_project",
"path": "/src/entities.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn alignment_view_distance_circle(&self, ctx: &mut Context, alignment_view_distance: f32) -> graphics::Mesh {
MeshBuilder::new().circle(
graphics::DrawMode::stroke(1.0),
Point2::new(self.pos.x, self.pos.y),
alignment_view_distance,
1.0,
... | code_fim | hard | {
"lang": "rust",
"repo": "Ivaylogi98/boids_rust_project",
"path": "/src/entities.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ivaylogi98/boids_rust_project path: /src/entities.rs
use ggez::{Context, GameResult};
use ggez::graphics;
use ggez::graphics::{Mesh, MeshBuilder, DrawMode};
use ggez::nalgebra::{Point2, Vector2};
use crate::assets::Assets;
use crate::tools::Tools;
#[derive(Debug, Copy, Clone)]
pub struct Bird... | code_fim | hard | {
"lang": "rust",
"repo": "Ivaylogi98/boids_rust_project",
"path": "/src/entities.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(Self(<[u8; Self::LEN]>::try_from(value).with_context(
|| len_err_msg(value.len(), Self::LEN, "Public key"),
)?))
}
}
impl From<ed25519_dalek::PublicKey> for Public {
fn from(v: ed25519_dalek::PublicKey) -> Self {
Self(*v.as_bytes())
}
}
impl std::fmt::U... | code_fim | hard | {
"lang": "rust",
"repo": "fsabado/feeless",
"path": "/src/keys/public.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fsabado/feeless path: /src/keys/public.rs
#[cfg(feature = "node")]
use crate::node::Wire;
#[cfg(feature = "node")]
use crate::node::Header;
use crate::encoding::deserialize_from_str;
use crate::{encoding, expect_len, len_err_msg, to_hex, Address, Signature};
use anyhow::Context;
use bitvec::pr... | code_fim | hard | {
"lang": "rust",
"repo": "fsabado/feeless",
"path": "/src/keys/public.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn deserialize(_header: Option<&Header>, _data: &[u8]) -> anyhow::Result<Self>
where
Self: Sized,
{
unimplemented!()
}
fn len(_header: Option<&Header>) -> anyhow::Result<usize>
where
Self: Sized,
{
Ok(Self::LEN)
}
}
/// A serde serializer t... | code_fim | hard | {
"lang": "rust",
"repo": "fsabado/feeless",
"path": "/src/keys/public.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>rgd_word1::R) reader structure"]
impl crate::Readable for RGD_WORD1 {}
#[doc = "`write(|w| ..)` method takes [rgd_word1::W](rgd_word1::W) writer structure"]
impl crate::Writable for RGD_WORD1 {}
#[doc = "Region Descriptor n, Word 1"]
pub mod rgd_word1;
#[doc = "Region Descriptor n, Word 2\n\nThis register... | code_fim | hard | {
"lang": "rust",
"repo": "thorhs/mk66f18",
"path": "/src/sysmpu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>R = crate::Reg<u32, _CESR>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _CESR;
#[doc = "`read()` method returns [cesr::R](cesr::R) reader structure"]
impl crate::Readable for CESR {}
#[doc = "`write(|w| ..)` method takes [cesr::W](cesr::W) writer structure"]
impl crate::Writable for CESR {}
#[doc = "... | code_fim | hard | {
"lang": "rust",
"repo": "thorhs/mk66f18",
"path": "/src/sysmpu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thorhs/mk66f18 path: /src/sysmpu.rs
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Control/Error Status Register"]
pub cesr: CESR,
_reserved1: [u8; 12usize],
#[doc = "0x10 - Error Address Register, slave port n"]
pub ear0: EAR,
#[doc = "0... | code_fim | hard | {
"lang": "rust",
"repo": "thorhs/mk66f18",
"path": "/src/sysmpu.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andrewpedia/cashbox path: /demo/ffi/orm_rustorm/lib.rs
use std::os::raw::c_char;
// use chrono::{
// offset::Utc,
// DateTime,
// NaiveDate,
// };
use rustorm::{DbError, FromDao, Pool, ToColumnNames, ToDao, ToTableName, rustorm_dao, Value};
use std::ops::Add;
#[no_mangle]
pub extern... | code_fim | hard | {
"lang": "rust",
"repo": "andrewpedia/cashbox",
"path": "/demo/ffi/orm_rustorm/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> log::info!("tryRustOrm");
let db_name = shared::to_str(name);
if std::fs::metadata(db_name).is_err() {
let file = std::fs::File::create(db_name);
if file.is_err() {
log::info!("{:?}",file.err().unwrap());
}
}
let db_url = "sqlite://".to_owned().add(d... | code_fim | hard | {
"lang": "rust",
"repo": "andrewpedia/cashbox",
"path": "/demo/ffi/orm_rustorm/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let actors = vec![tom_cruise, tom_hanks];
for actor in actors {
let first_name: Value = actor.first_name.into();
let last_name: Value = actor.last_name.into();
let ret = em.db().execute_sql_with_return(
"INSERT INTO actor(first_name, last_name)
VALU... | code_fim | hard | {
"lang": "rust",
"repo": "andrewpedia/cashbox",
"path": "/demo/ffi/orm_rustorm/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) fn anchor_lang_crate_name() -> Ident {
match crate_name("anchor_lang") {
Ok(FoundCrate::Itself) => Ident::new("crate", Span::call_site()),
Ok(FoundCrate::Name(name)) => Ident::new(&name, Span::call_site()),
Err(_) => Ident::new("anchor_lang", Span::call_site()),
... | code_fim | easy | {
"lang": "rust",
"repo": "markoinether/anchor",
"path": "/lang/syn/src/codegen/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: markoinether/anchor path: /lang/syn/src/codegen/mod.rs
use proc_macro2::Span;
use syn::Ident;
pub mod error;
pub mod program;
<|fim_suffix|>pub(crate) fn anchor_lang_crate_name() -> Ident {
match crate_name("anchor_lang") {
Ok(FoundCrate::Itself) => Ident::new("crate", Span::call_s... | code_fim | easy | {
"lang": "rust",
"repo": "markoinether/anchor",
"path": "/lang/syn/src/codegen/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dennisss/dacha path: /pkg/protobuf/core/src/lib.rs
#![feature(core_intrinsics, trait_alias)]
#![no_std]
#[cfg(feature = "std")]
#[macro_use]
extern crate std;
#[cfg(feature = "alloc")]
#[macro_use]
extern crate alloc;
<|fim_suffix|>#[cfg(feature = "std")]
#[macro_use]
extern crate parsing;
#... | code_fim | medium | {
"lang": "rust",
"repo": "dennisss/dacha",
"path": "/pkg/protobuf/core/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct StaticFileDescriptor {
pub proto: &'static [u8],
pub dependencies: &'static [&'static StaticFileDescriptor],
}
pub const TYPE_URL_PREFIX: &'static str = "type.googleapis.com/";<|fim_prefix|>// repo: dennisss/dacha path: /pkg/protobuf/core/src/lib.rs
#![feature(core_intrinsics, trait_a... | code_fim | hard | {
"lang": "rust",
"repo": "dennisss/dacha",
"path": "/pkg/protobuf/core/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aldrio/omdb-rs path: /src/error.rs
use std::error::Error as StdError;
use std::fmt;
use reqwest::StatusCode;
#[derive(Debug)]
pub enum Error {
/// An error originating from Reqwest.
Http(reqwest::Error),
/// An unexpected HTTP status code.
Status(StatusCode),
/// An error f... | code_fim | medium | {
"lang": "rust",
"repo": "aldrio/omdb-rs",
"path": "/src/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
Error::Http(ref err) => err.fmt(f),
Error::Status(status) => status.canonical_reason().unwrap_or("Unknown status").fmt(f),
Error::Api(ref desc) => desc.fmt(f),
Error::Other(desc) => desc.fmt(f),
}
}
}<|fim_prefix|>// repo: al... | code_fim | hard | {
"lang": "rust",
"repo": "aldrio/omdb-rs",
"path": "/src/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Error::Http(err)
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Error::Http(ref err) => err.fmt(f),
Error::Status(status) => status.canonical_reason().unwrap_or("Unknown status").fmt(f),
Err... | code_fim | medium | {
"lang": "rust",
"repo": "aldrio/omdb-rs",
"path": "/src/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("In Order Strategy = {:?}",in_order_stat);
//let random_stat = accumulate_statistics_par(WinLossStatistic::default(), GameGenerator::<RandomPickingStrategy>::new(num_games));
//println!("Random Strategy = {:?}",random_stat);
}<|fim_prefix|>// repo: geo-ant/rusty-orchard path: /src/mai... | code_fim | hard | {
"lang": "rust",
"repo": "geo-ant/rusty-orchard",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: geo-ant/rusty-orchard path: /src/main.rs
mod orchard;
//use game::GameState;
use crate::orchard::strategies::{InOrderPickingStrategy,RandomPickingStrategy};
use crate::orchard::generator::GameGenerator;
use crate::orchard::statistics::{accumulate_statistics_par,accumulate_statistics_seq};
use c... | code_fim | hard | {
"lang": "rust",
"repo": "geo-ant/rusty-orchard",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for packet_index in 0..packet_count {
let packet_index = packet_index as u8;
let mut message = vec![0x56, 0x83, packet_index, 0x00];
let packet = data
.chunks(payload_len)
.nth(packet_index as usize)
.unwrap_or_def... | code_fim | hard | {
"lang": "rust",
"repo": "panicbit/duckyctl",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: panicbit/duckyctl path: /src/lib.rs
use anyhow::*;
use hidapi::{HidApi, HidDevice};
const VID_DUCKY: u16 = 0x04d9;
const PID_DUCKY_ONE_2_RGB_TKL: u16 = 0x0356;
pub fn hid() -> hidapi::HidResult<HidApi> {
HidApi::new()
}
pub struct Keyboard {
device: HidDevice,
colors: Vec<u8>,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "panicbit/duckyctl",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(r.time)
}
fn intersect_p(&self, r: &Ray) -> bool {
let interpolated_prim_to_world = self.primitive_to_world.interpolate(r.time);
let ray = interpolated_prim_to_world.invert().transform_ray(r);
self.primitive.intersect_p(&ray)
}
}
impl Material for Transfo... | code_fim | hard | {
"lang": "rust",
"repo": "ssttuu/pbrt-rs",
"path": "/src/primitive.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ssttuu/pbrt-rs path: /src/primitive.rs
use crate::bounds::Bounds3;
use crate::interaction::SurfaceInteraction;
use crate::intersect::Intersect;
use crate::lights::area::AreaLight;
use crate::materials::Material;
use crate::materials::TransportMode;
use crate::medium::MediumInterface;
use crate::... | code_fim | hard | {
"lang": "rust",
"repo": "ssttuu/pbrt-rs",
"path": "/src/primitive.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(t_hit)
}
fn intersect_p(&self, r: &Ray) -> bool {
self.shape.intersect_p(r, true)
}
}
impl Material for GeometricPrimitive {
fn compute_scattering_functions(
&self,
si: &mut SurfaceInteraction,
mode: TransportMode,
allow_multiple_lobes... | code_fim | hard | {
"lang": "rust",
"repo": "ssttuu/pbrt-rs",
"path": "/src/primitive.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sample_rate: i32 = self.decoder.stream_info().sampleRate;
sample_rate as _
}
fn total_duration(&self) -> Option<Duration> {
return None;
}
}
fn get_bits(byte: u16, range: Range<u16>) -> u16 {
let shaved_left = byte << range.start - 1;
let moved_back = shave... | code_fim | hard | {
"lang": "rust",
"repo": "vgarleanu/mp4-rust",
"path": "/examples/mpeg_aac_decoder/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vgarleanu/mp4-rust path: /examples/mpeg_aac_decoder/src/main.rs
use fdk_aac::dec::{Decoder, DecoderError, Transport};
use rodio::{OutputStream, Sink, Source};
use std::fs::File;
use std::io::{BufReader, Read, Seek};
use std::ops::Range;
use std::time::Duration;
fn main() {
let path = "audio... | code_fim | hard | {
"lang": "rust",
"repo": "vgarleanu/mp4-rust",
"path": "/examples/mpeg_aac_decoder/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let shaved_left = byte << range.start - 1;
let moved_back = shaved_left >> range.start - 1;
let shave_right = moved_back >> 8 - range.end;
return shave_right;
}
pub fn construct_adts_header(track: &mp4::Mp4Track, sample: &mp4::Mp4Sample) -> Option<Vec<u8>> {
// B: Only support 0 (MPEG... | code_fim | hard | {
"lang": "rust",
"repo": "vgarleanu/mp4-rust",
"path": "/examples/mpeg_aac_decoder/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>erialize, Debug)]
pub enum MsgClass {
BLOCK(Block),
SYNCREQ(H256),
TX(SignedTransaction),
MSG(Vec<u8>)<|fim_prefix|>// repo: 0xneox/chit path: /network/src/msgclass.rs
use chain::block::Block;
use chain::transaction::SignedTr<|fim_middle|>ansaction;
use util::hash::H256;
#[derive(Serialize, ... | code_fim | easy | {
"lang": "rust",
"repo": "0xneox/chit",
"path": "/network/src/msgclass.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0xneox/chit path: /network/src/msgclass.rs
use chain::block::Block;
use chain::transaction::SignedTr<|fim_suffix|>erialize, Debug)]
pub enum MsgClass {
BLOCK(Block),
SYNCREQ(H256),
TX(SignedTransaction),
MSG(Vec<u8>)<|fim_middle|>ansaction;
use util::hash::H256;
#[derive(Serialize, ... | code_fim | easy | {
"lang": "rust",
"repo": "0xneox/chit",
"path": "/network/src/msgclass.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> SYNCREQ(H256),
TX(SignedTransaction),
MSG(Vec<u8>)<|fim_prefix|>// repo: 0xneox/chit path: /network/src/msgclass.rs
use chain::block::Block;
use chain::transaction::SignedTr<|fim_middle|>ansaction;
use util::hash::H256;
#[derive(Serialize, Deserialize, Debug)]
pub enum MsgClass {
BLOCK(Block)... | code_fim | medium | {
"lang": "rust",
"repo": "0xneox/chit",
"path": "/network/src/msgclass.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jethrosun/peel-ip path: /benches/ipv4.rs
#![feature(test)]
extern crate peel_ip;
extern crate test;
use test::Bencher;
use peel_ip::prelude::*;
static PACKET: &'static [u8] = &[0x45, 0x00, 0x01, 0xa5, 0xd6, 0x63, 0x40, 0x00, 0x3f, 0x06, 0x9b, 0xfc, 0xc0, 0xa8,
... | code_fim | medium | {
"lang": "rust",
"repo": "jethrosun/peel-ip",
"path": "/benches/ipv4.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut parser = Ipv4Parser;
let mut input = Vec::from(PACKET);
input.extend_from_slice(&[0xff; 1450]);
bencher.iter(|| {
parser.parse(&input, None, None).unwrap();
});
bencher.bytes = input.len() as u64;
}<|fim_prefix|>// repo: jethrosun/peel-ip path: /benches/ipv4.rs
#![... | code_fim | hard | {
"lang": "rust",
"repo": "jethrosun/peel-ip",
"path": "/benches/ipv4.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[bench]
fn ipv4_big_packet(bencher: &mut Bencher) {
let mut parser = Ipv4Parser;
let mut input = Vec::from(PACKET);
input.extend_from_slice(&[0xff; 1450]);
bencher.iter(|| {
parser.parse(&input, None, None).unwrap();
});
bencher.bytes = input.len() as u64;
}<|fim_prefix|>/... | code_fim | hard | {
"lang": "rust",
"repo": "jethrosun/peel-ip",
"path": "/benches/ipv4.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>The number of nodes in the list is in the range [0, 100].
0 <= Node.val <= 100
*/
// Definition for singly-linked list.
// #[derive(PartialEq, Eq, Clone, Debug)]
// pub struct ListNode {
// pub val: i32,
// pub next: Option<Box<ListNode>>
// }
//
// impl ListNode {
// #[inline]
// fn new(val: i3... | code_fim | medium | {
"lang": "rust",
"repo": "loganyu/leetcode",
"path": "/problems/024_swap_nodes_in_pairs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: loganyu/leetcode path: /problems/024_swap_nodes_in_pairs.rs
/*
Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.)
Example 1:
Input: head = [1,2,3,4... | code_fim | medium | {
"lang": "rust",
"repo": "loganyu/leetcode",
"path": "/problems/024_swap_nodes_in_pairs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cannot_refract = refraction_ratio * sin_theta > 1.0;
let mut direction = vec3 {e:[0.0,0.0,0.0]};
if cannot_refract {
direction = reflect(&unit_direction, &rec.normal);
} else {
direction = refract(&unit_direction, &rec.normal, refraction_ratio);... | code_fim | hard | {
"lang": "rust",
"repo": "ShoshinX/RayTracing",
"path": "/src/material.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if cannot_refract {
direction = reflect(&unit_direction, &rec.normal);
} else {
direction = refract(&unit_direction, &rec.normal, refraction_ratio);
}
*scattered = ray{orig: rec.p, dir: direction};
true
}
}
fn reflectance(cosine: f64, re... | code_fim | hard | {
"lang": "rust",
"repo": "ShoshinX/RayTracing",
"path": "/src/material.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ShoshinX/RayTracing path: /src/material.rs
use crate::rtweekend::*;
use crate::hittable::*;
use crate::ray::*;
use crate::vec3::*;
pub trait material{
fn scatter(&self,r_in: &ray, rec: &hit_record, attenuation: &mut color, scattered: &mut ray) -> bool;
}
pub struct lambertian {
pub alb... | code_fim | medium | {
"lang": "rust",
"repo": "ShoshinX/RayTracing",
"path": "/src/material.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IncompleteWorlds/07_GSaaS_Rust path: /07_GSaaS_Rust/05_Common/src/common_messages.rs
/**
* (c) Incomplete Worlds 2021
* Alberto Fernandez (ajfg)
*
* GS as a Service
* Common Data (messages) structures used in all the API.
*/
//use std::result::Result;
use std::error;
use std::fmt;
use st... | code_fim | hard | {
"lang": "rust",
"repo": "IncompleteWorlds/07_GSaaS_Rust",
"path": "/07_GSaaS_Rust/05_Common/src/common_messages.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn new_value(in_msg_code: String, in_msg_id: String, in_value: Value, in_execution_id: u32) -> Self {
InternalResponseMessage {
response: RestResponse::new_value(in_msg_code, in_msg_id, in_value),
execution_id: in_execution_id,
wait_flag: false... | code_fim | hard | {
"lang": "rust",
"repo": "IncompleteWorlds/07_GSaaS_Rust",
"path": "/07_GSaaS_Rust/05_Common/src/common_messages.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[serde(flatten)]
pub parameters: Value,
}
impl ToString for RestRequest {
fn to_string(&self) -> String {
serde_json::to_string(self).expect("Should never failed")
}
}
impl RestRequest {
// Create a response of type error
pub fn new() -> Self {
R... | code_fim | hard | {
"lang": "rust",
"repo": "IncompleteWorlds/07_GSaaS_Rust",
"path": "/07_GSaaS_Rust/05_Common/src/common_messages.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(not(feature = "poll_debugger"))]
mod exts {
use super::*;
pub trait FutureDebugExt: Sized {
fn debug_poll(self, _: &'static str) -> Self {
self
}
}
pub trait StreamDebugExt: Sized {
fn debug_poll_next(self, _: &'static str) -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/lowpan/lib/lowpan_driver_common/src/poll_debugger.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> PollDebugger(self, what)
}
}
pub trait StreamDebugExt: Sized {
fn debug_poll_next(self, what: &'static str) -> PollDebugger<Self> {
PollDebugger(self, what)
}
}
impl<F: Future + Unpin> FutureDebugExt for F {}
impl<F: Stream + Unpin> Str... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/lowpan/lib/lowpan_driver_common/src/poll_debugger.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/connectivity/lowpan/lib/lowpan_driver_common/src/poll_debugger.rs
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use core::future::Future;
use core::p... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/lowpan/lib/lowpan_driver_common/src/poll_debugger.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: magiclen/educe path: /tests/deref_mut_enum.rs
#![cfg(all(feature = "Deref", feature = "DerefMut"))]
#![no_std]
#[macro_use]
extern crate educe;
#[test]
#[allow(dead_code)]
fn basic() {
<|fim_suffix|> let mut t2 = Enum::Tuple2(1, 2);
*s1 += 100;
*s2 += 100;
*t1 += 100;
*t2 ... | code_fim | hard | {
"lang": "rust",
"repo": "magiclen/educe",
"path": "/tests/deref_mut_enum.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut s2 = Enum::Struct2 {
f1: 1, f2: 2
};
let mut t1 = Enum::Tuple(1);
let mut t2 = Enum::Tuple2(1, 2);
*s1 += 100;
*s2 += 100;
*t1 += 100;
*t2 += 100;
assert_eq!(101, *s1);
assert_eq!(102, *s2);
assert_eq!(101, *t1);
assert_eq!(102, *t2);
}... | code_fim | hard | {
"lang": "rust",
"repo": "magiclen/educe",
"path": "/tests/deref_mut_enum.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> *s1 += 100;
*s2 += 100;
*t1 += 100;
*t2 += 100;
assert_eq!(101, *s1);
assert_eq!(102, *s2);
assert_eq!(101, *t1);
assert_eq!(102, *t2);
}<|fim_prefix|>// repo: magiclen/educe path: /tests/deref_mut_enum.rs
#![cfg(all(feature = "Deref", feature = "DerefMut"))]
#![no_std]... | code_fim | medium | {
"lang": "rust",
"repo": "magiclen/educe",
"path": "/tests/deref_mut_enum.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gbrls/tisp path: /src/tispc_parser/parser.rs
use crate::tispc_lexer::{Ident, LiteralKind, Token, TokenKind, Value};
#[derive(Debug, Clone, PartialEq)]
pub enum Expr<'a> {
Constant(Value<'a>),
Builtin(Ident<'a>),
Call(Box<Expr<'a>>, Vec<Expr<'a>>),
}
/// generate_expression_tree
///... | code_fim | hard | {
"lang": "rust",
"repo": "gbrls/tisp",
"path": "/src/tispc_parser/parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> TokenKind::CloseParen => {
let mut params: Vec<Expr> = Vec::new();
// pop elements from stack until a Builtin is found
loop {
let expr = stack.pop();
match expr {
Some(Expr::Builtin(... | code_fim | hard | {
"lang": "rust",
"repo": "gbrls/tisp",
"path": "/src/tispc_parser/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_non_fizz_buzz_value() {
assert_eq!(fizz_buzz(2), String::from("2"));
}
}<|fim_prefix|>// repo: staszewski/teaching-material-assignments path: /src/fizz_buzz.rs
pub fn fizz_buzz(i: i32) -> String {
if i % 3 == 0 && i % 5 == 0 {
String::from("FizzBuzz")
}... | code_fim | hard | {
"lang": "rust",
"repo": "staszewski/teaching-material-assignments",
"path": "/src/fizz_buzz.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: staszewski/teaching-material-assignments path: /src/fizz_buzz.rs
pub fn fizz_buzz(i: i32) -> String {
if i % 3 == 0 && i % 5 == 0 {
String::from("FizzBuzz")
} else if i % 3 == 0 {
String::from("Fizz")
} else if i % 5 == 0 {
String::from("Buzz")
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "staszewski/teaching-material-assignments",
"path": "/src/fizz_buzz.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: janpauldahlke/fhir-rs path: /src/model/Contract_Term.rs
#![allow(unused_imports, non_camel_case_types)]
use crate::model::CodeableConcept::CodeableConcept;
use crate::model::Contract_Action::Contract_Action;
use crate::model::Contract_Asset::Contract_Asset;
use crate::model::Contract_Offer::Con... | code_fim | hard | {
"lang": "rust",
"repo": "janpauldahlke/fhir-rs",
"path": "/src/model/Contract_Term.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn applies<'a>(&'a mut self, val: Period) -> &'a mut Contract_TermBuilder {
self.value["applies"] = json!(val.value);
return self;
}
pub fn asset<'a>(&'a mut self, val: Vec<Contract_Asset>) -> &'a mut Contract_TermBuilder {
self.value["asset"] = json!(val.into_iter... | code_fim | hard | {
"lang": "rust",
"repo": "janpauldahlke/fhir-rs",
"path": "/src/model/Contract_Term.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// A legal clause or condition contained within a contract that requires one or
/// both parties to perform a particular requirement by some specified time or
/// prevents one or both parties from performing a particular requirement by some
/// specified time.
pub fn fhir_type(&self) ... | code_fim | hard | {
"lang": "rust",
"repo": "janpauldahlke/fhir-rs",
"path": "/src/model/Contract_Term.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LiveSplit/livesplit-core path: /src/platform/wasm/mod.rs
cfg_if::cfg_if! {
if #[cfg(feature = "wa<|fim_suffix|>wn;
pub use self::unknown::*;
}
}<|fim_middle|>sm-web")] {
mod web;
pub use self::web::*;
} else {
mod unkno | code_fim | medium | {
"lang": "rust",
"repo": "LiveSplit/livesplit-core",
"path": "/src/platform/wasm/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>self::web::*;
} else {
mod unknown;
pub use self::unknown::*;
}
}<|fim_prefix|>// repo: LiveSplit/livesplit-core path: /src/platform/wasm/mod.rs
cfg_if::cfg_if! {
if #[cfg(feature = "wa<|fim_middle|>sm-web")] {
mod web;
pub use | code_fim | easy | {
"lang": "rust",
"repo": "LiveSplit/livesplit-core",
"path": "/src/platform/wasm/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eupn/stm32wb-pac path: /src/exti/verr.rs
#[doc = "Reader of register VERR"]
pub type R = crate::R<u32, super::VERR>;
#[doc = "Reader of field `MINREV`"]
pub type MINREV_R = crate::R<<|fim_suffix|> Revision number"]
#[inline(always)]
pub fn majrev(&self) -> MAJREV_R {
MAJREV_R::ne... | code_fim | hard | {
"lang": "rust",
"repo": "eupn/stm32wb-pac",
"path": "/src/exti/verr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline(always)]
pub fn minrev(&self) -> MINREV_R {
MINREV_R::new((self.bits & 0x0f) as u8)
}
#[doc = "Bits 4:7 - Major Revision number"]
#[inline(always)]
pub fn majrev(&self) -> MAJREV_R {
MAJREV_R::new(((self.bits >> 4) & 0x0f) as u8)
}
}<|fim_prefix|>// repo:... | code_fim | medium | {
"lang": "rust",
"repo": "eupn/stm32wb-pac",
"path": "/src/exti/verr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CmdrMoozy/euler path: /src/bin/00010.rs
// Copyright 2013 Axel Rasmussen
//
// 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 License at
//
// http://www.apache.org/licenses/LICEN... | code_fim | hard | {
"lang": "rust",
"repo": "CmdrMoozy/euler",
"path": "/src/bin/00010.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>use euler::math::prime::PrimeSieve;
use euler::util::error::*;
use euler::util::problem::*;
// Although we want primes *less than* two million, two million itself is
// clearly composite, so we can use it as an upper bound.
const PRIME_SIEVE_LIMIT: u64 = 2000000;
const EXPECTED_RESULT: u64 = 142913828922... | code_fim | medium | {
"lang": "rust",
"repo": "CmdrMoozy/euler",
"path": "/src/bin/00010.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jssgen/ik-rust path: /funcoes/src/[]
extern crate time;
fn dia_atual() {
let d = time::now();
const O_1900: i32 = 1900;
println!(
"Hoje é dia {}/{}/{}",
d.tm_mday,
d.tm_mon,
d.tm_year + O_1900
);
}
fn soma(x: i32, y: i32) -> i32 {
<|fim_suffix|> ... | code_fim | medium | {
"lang": "rust",
"repo": "jssgen/ik-rust",
"path": "/funcoes/src/[]",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> function();
}
fn printar() {
println!("Olá!");
}
fn main() {
dia_atual();
let x = 5;
let y = 8;
let a = 3;
let b = 9;
println!("{} + {} = {}", x, y, soma(x, y));
fn sum(a: i32, b: i32) -> i32 {
a + b
}
println!("{} + {} = {}", a, b, sum(a, b));
let f... | code_fim | medium | {
"lang": "rust",
"repo": "jssgen/ik-rust",
"path": "/funcoes/src/[]",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>### Design notes
All operations on the filesystem require passing a `&mut Storage`, which guarantees by Rust's
borrow checker that only one thread can manipulate the filesystem.
This design choice (as opposed to consuming the Storage, which would be less verbose) was made to
enable use of the underlying ... | code_fim | hard | {
"lang": "rust",
"repo": "3mdeb/littlefs2",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 3mdeb/littlefs2 path: /src/lib.rs
#![cfg_attr(not(test), no_std)]
/*!
[littlefs](https://github.com/ARMmbed/littlefs) is a filesystem for microcontrollers
written in C, that claims to be *fail-safe*:
- power-loss resilience, by virtue of copy-on-write guarantees
- bounded RAM/ROM, with stack-a... | code_fim | hard | {
"lang": "rust",
"repo": "3mdeb/littlefs2",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|><https://play.rust-lang.org/?edition=2018&gist=c86abf99fc87551cfe3136e398a45d19>
Separately, keeping track of the allocations is a chore, we hope that
[`Pin`](https://doc.rust-lang.org/core/pin/index.html) magic will help fix this.
### Example
```
# use littlefs2::fs::{Filesystem, File, OpenOptions};
#... | code_fim | hard | {
"lang": "rust",
"repo": "3mdeb/littlefs2",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let bytes = read_file_as_bytes(Path::new("test/read_file_as_bytes_empty"));
assert_that!(&bytes, is(of_len(0)));
}
#[test]
fn read_file_as_bytes_usual_file() {
let bytes = read_file_as_bytes(Path::new("test/read_file_as_bytes"));
assert_that!(bytes, is(equal_... | code_fim | hard | {
"lang": "rust",
"repo": "Weltraumschaf/minivm",
"path": "/src/commands/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Weltraumschaf/minivm path: /src/commands/mod.rs
///! This module provides the various CLI command implementations.
mod assemble_command;
mod compile_command;
mod disassemble_command;
mod parse_command;
mod run_command;
use std::path::Path;
use std::fs::File;
use std::io::prelude::*;
pub use s... | code_fim | medium | {
"lang": "rust",
"repo": "Weltraumschaf/minivm",
"path": "/src/commands/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn read_file_as_bytes_file_is_empty() {
let bytes = read_file_as_bytes(Path::new("test/read_file_as_bytes_empty"));
assert_that!(&bytes, is(of_len(0)));
}
#[test]
fn read_file_as_bytes_usual_file() {
let bytes = read_file_as_bytes(Path::new("test/read_... | code_fim | hard | {
"lang": "rust",
"repo": "Weltraumschaf/minivm",
"path": "/src/commands/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Alexandre-Herve/gaia path: /src/domain/models/in_days.rs
#[derive(Debug)]
pub struct InDays<'a, T>(pub u32, pub &'a T);
impl<'a, T> InDays<'a, T> {
pub fn new(days: u32, data: &T) -> InDays<T> {
InDays(days, data)
}
pub fn in_days(&self) -> u32 {
self.0
}
p... | code_fim | medium | {
"lang": "rust",
"repo": "Alexandre-Herve/gaia",
"path": "/src/domain/models/in_days.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let d = InDays(1, &2);
assert_eq!(d.value(), &2)
}
}<|fim_prefix|>// repo: Alexandre-Herve/gaia path: /src/domain/models/in_days.rs
#[derive(Debug)]
pub struct InDays<'a, T>(pub u32, pub &'a T);
impl<'a, T> InDays<'a, T> {
pub fn new(days: u32, data: &T) -> InDays<T> {
In... | code_fim | hard | {
"lang": "rust",
"repo": "Alexandre-Herve/gaia",
"path": "/src/domain/models/in_days.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZacharyPuls/rust-ide path: /src/main.rs
extern crate winapi;
extern crate gui;
use winapi::types::HBRUSH;
use gui::window::create_window;
<|fim_suffix|>#[link_args = "-Wl,--subsystem,windows"]
fn main() {
println!("RustIDE Version {}", VERSION);
unsafe {
create_window("RustIDE... | code_fim | medium | {
"lang": "rust",
"repo": "ZacharyPuls/rust-ide",
"path": "/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[link_args = "-Wl,--subsystem,windows"]
fn main() {
println!("RustIDE Version {}", VERSION);
unsafe {
create_window("RustIDE", 300, 300, 640, 480, 5 as HBRUSH);
}
}<|fim_prefix|>// repo: ZacharyPuls/rust-ide path: /src/main.rs
extern crate winapi;
extern crate gui;
use winapi::types... | code_fim | medium | {
"lang": "rust",
"repo": "ZacharyPuls/rust-ide",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danbsmith/rs-schedule-server path: /src/serve/mod.rs
mod actions;
mod html_gen;
use crate::schedule::*;
use crate::BoxFut;
use html_gen::*;
use hyper::{Body, Request, StatusCode};
pub fn web(
req: Request<Body>,
schedules: &std::sync::Arc<std::sync::Mutex<std::vec::Vec<Schedule>>>,
... | code_fim | hard | {
"lang": "rust",
"repo": "danbsmith/rs-schedule-server",
"path": "/src/serve/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> filepath,
);
} else if path_parts.len() == 2 && path_parts[0].eq("delete") {
return actions::delete_sched(path_parts[1], schedules.clone(), filepath);
} else {
return html_future_ok(
String::from("<p>No posting... | code_fim | hard | {
"lang": "rust",
"repo": "danbsmith/rs-schedule-server",
"path": "/src/serve/mod.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.