text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> Event::Start(Tag::Image(src, title))
}
Event::Start(Tag::Link(link, title)) => {
// A few situations here:
// - it could be a relative link (starting with `./`)
// - it could be a link to a co-l... | code_fim | hard | {
"lang": "rust",
"repo": "sgeisler/gutenberg",
"path": "/components/rendering/src/markdown.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // if we are in the middle of a code block
if let Some(ref mut highlighter) = highlighter {
let highlighted = &highlighter.highlight(&text);
let html = styles_to_coloured_html(highlighted, IncludeBackground::Yes);
... | code_fim | hard | {
"lang": "rust",
"repo": "sgeisler/gutenberg",
"path": "/components/rendering/src/markdown.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model test2 {
updated_at DateTime @updatedAt
other String?
reference Int
@@id([reference, updated_at])
}
"#
.to_owned()
}
#[connector_test(exclude(Mongodb))]
async fn create_one_model_with... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/connector-test-kit-rs/query-engine-tests/tests/new/regressions/prisma_15581.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> r#"
model test {
reference Int
created_at DateTime @default(now()) @test.Timestamptz(1)
other String?
@@id([reference, created_at])
}
"#
.to_owned()
}
#[connector_test(only(Postgres), ... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/connector-test-kit-rs/query-engine-tests/tests/new/regressions/prisma_15581.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nerosnm/punch-clock path: /src/period.rs
use std::{
fmt::{Display, Formatter, Result as FmtResult},
str::FromStr,
};
/// Represents a period of time relative to now.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Period {
/// The period of time that began at the start of the first ... | code_fim | hard | {
"lang": "rust",
"repo": "nerosnm/punch-clock",
"path": "/src/period.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
Period::All => write!(f, "All-Time"),
Period::Today => write!(f, "Today"),
Period::Yesterday => write!(f, "Yesterday"),
Period::Week => write!(f, "This Week"),
Period::LastWeek => write!(f, "Last Week"),
Period::M... | code_fim | medium | {
"lang": "rust",
"repo": "nerosnm/punch-clock",
"path": "/src/period.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
::blocking_io(|| fs::read_link(&self.path) )
}
}<|fim_prefix|>// repo: ry/tokio path: /tokio-fs/src/read_link.rs
use std::fs;
use std::io;
use std::path::{Path, PathBuf};
use futures::{Future, Poll};
/// Reads a symbolic link, return... | code_fim | medium | {
"lang": "rust",
"repo": "ry/tokio",
"path": "/tokio-fs/src/read_link.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ry/tokio path: /tokio-fs/src/read_link.rs
use std::fs;
use std::io;
use std::path::{Path, PathBuf};
use futures::{Future, Poll};
/// Reads a symbolic link, returning the file that the link points to.
///
/// This is an async version of [`std::fs::read_link`][std]
///
/// [std]: https://doc.rus... | code_fim | hard | {
"lang": "rust",
"repo": "ry/tokio",
"path": "/tokio-fs/src/read_link.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: voidxnull/ff-uint path: /src/uint/traits.rs
pub trait Uint:
Sized +
Clone +
Copy +
Default +
std::cmp::PartialEq +
std::cmp::PartialOrd +
std::cmp::Eq +
std::cmp::Ord +
std::ops::Add<Self> +
std::ops::Sub<Self> +
std::ops::Mul<Self> +
std::ops::Mul<u64> +
std::ops::Div<Self> +
... | code_fim | hard | {
"lang": "rust",
"repo": "voidxnull/ff-uint",
"path": "/src/uint/traits.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.overflowing_neg().0
}
/// Checked negation. Returns `None` unless `self == 0`.
#[inline]
fn checked_neg(self) -> Option<Self> {
match self.overflowing_neg() {
(_, true) => None,
(zero, false) => Some(zero),
}
}
#[inline]
fn wrapping_shr(self, rhs: u32) -> Self {
self.overflowin... | code_fim | hard | {
"lang": "rust",
"repo": "voidxnull/ff-uint",
"path": "/src/uint/traits.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reem/mio path: /test/test_close_on_drop.rs
use mio::*;
use mio::buf::ByteBuf;
use super::localhost;
struct TestHandler {
srv: TcpAcceptor,
cli: TcpSocket
}
impl TestHandler {
fn new(srv: TcpAcceptor, cli: TcpSocket) -> TestHandler {
<|fim_suffix|> let srv = TcpSocket::v4().unwra... | code_fim | hard | {
"lang": "rust",
"repo": "reem/mio",
"path": "/test/test_close_on_drop.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> info!("listening for connections");
reactor.listen(&srv, 256u, 0u).unwrap();
let sock = TcpSocket::v4().unwrap();
// Connect to the server
reactor.connect(&sock, &addr, 1u).unwrap();
// Start the reactor
reactor.run(TestHandler::new(srv, sock))
.ok().expect("failed t... | code_fim | hard | {
"lang": "rust",
"repo": "reem/mio",
"path": "/test/test_close_on_drop.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pierremarc/http_static path: /src/file_serving.rs
use bytes::BytesMut;
use futures::future::{ok, Either};
use http::{self, header};
use mime_guess::guess_mime_type;
use mime_guess::Mime;
use std::sync::Arc;
use std::{io, path::PathBuf};
use tokio::{fs::File as TokioFile, prelude::Future};
use to... | code_fim | hard | {
"lang": "rust",
"repo": "pierremarc/http_static",
"path": "/src/file_serving.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut root = self.root.clone();
let default = self.default.clone();
root.push(&*self.index);
TokioFile::open(root.clone())
.map(move |f| File::new(f, guess_mime_type(root)))
.or_else(move |_| {
TokioFile:... | code_fim | hard | {
"lang": "rust",
"repo": "pierremarc/http_static",
"path": "/src/file_serving.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[get("/*relative_path")]
fn files(&self, relative_path: PathBuf) -> impl Future<Item = File, Error = io::Error> {
let mut path = self.root.clone();
path.push(relative_path);
let index = self.index.clone();
let default = self.default.clone()... | code_fim | hard | {
"lang": "rust",
"repo": "pierremarc/http_static",
"path": "/src/file_serving.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RonquilloAeon/rusty-currency path: /src/main.rs
extern crate clap;
use clap::{Arg, App};
use rust_decimal::{Decimal, RoundingStrategy};
use std::str::FromStr;
<|fim_suffix|> println!(
"{} USD equals {}",
amount_to_convert,
perform_conversion(amount_to_convert, conve... | code_fim | hard | {
"lang": "rust",
"repo": "RonquilloAeon/rusty-currency",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> amt * rate
}
fn main() {
let conversion_rate = Decimal::new(907820, 6);
let matches = App::new("rusty_currency")
.version("0.1")
.about("Convert USD to EUR")
.arg(
Arg::with_name("amount")
.short("a")
.long("amount")
... | code_fim | medium | {
"lang": "rust",
"repo": "RonquilloAeon/rusty-currency",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rutrum/diet-database path: /web/src/page/metric.rs
use crate::api_call::ApiCall;
use diet_database::metric::*;
use seed::{prelude::*, *};
use super::*;
use crate::form::*;
pub enum Msg {
Fetch,
Fetched(Result<Vec<Metric>, PageError>),
FormUpdate(FormMsg),
Edit(usize),
Delet... | code_fim | hard | {
"lang": "rust",
"repo": "rutrum/diet-database",
"path": "/web/src/page/metric.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FromInputData for NewMetric {
fn from_input_data(inputs: Vec<InputData>) -> Result<Self, PageError> {
Ok(NewMetric {
date: inputs[0].try_date()?,
time: inputs[1].try_time_option()?,
body_fat: inputs[2].try_float_option()?,
gut_circum: inputs... | code_fim | hard | {
"lang": "rust",
"repo": "rutrum/diet-database",
"path": "/web/src/page/metric.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/quick-error/src/lib.rs
ttyp
:
ty
)
+
)
)
*
)
{
(
{
(
svar
:
ident
:
styp
:
ty
)
*
}
)
*
}
)
*
]
queue
[
(
#
[
qmeta
:
meta
]
)
*
=
>
qitem
:
ident
:
TUPLE
[
(
qvar
:
ident
:
qtyp
:
ty
)
+
]
(
queue
:
tt
)
*
]
)
=
>
{
quick... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/quick-error/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
unused_doc_comments
)
]
impl
:
:
std
:
:
fmt
:
:
Display
for
name
{
fn
fmt
(
&
self
fmt
:
&
mut
:
:
std
:
:
fmt
:
:
Formatter
)
-
>
:
:
std
:
:
fmt
:
:
Result
{
match
*
self
{
(
(
#
[
imeta
]
)
*
quick_error
!
(
ITEM_PATTERN
name
item
:
imode
[
(
ref
var
)
*
]
)
=
>
{
let
display_fn
=
quick_error
!
(
FIN... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/quick-error/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>dent
:
AsRef
<
ctyp
:
ty
>
fvar
:
ident
:
ftyp
:
ty
)
-
>
{
(
tvar
:
ident
:
texpr
:
expr
)
*
}
(
tail
:
tt
)
*
}
)
=
>
{
impl
<
T
:
AsRef
<
ctyp
>
>
From
<
crate
:
:
Context
<
T
ftyp
>
>
for
name
{
fn
from
(
crate
:
:
Context
(
cvar
fvar
)
:
crate
:
:
Context
<
ctyp
ftyp
>
)
-
>
name
{
name
:
:
item
{
(
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/quick-error/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(super) fn log_ctx(&mut self, ctx: &InferCtx) {
if !self.does_log { return; }
writeln!(self.out, "current context:\n{}", ctx).unwrap();
}
}<|fim_prefix|>// repo: sabikin/Fourier path: /src/core/log.rs
use super::typechk::*;
use std::io::{Write, BufWriter};
struct Logger<W: Wr... | code_fim | medium | {
"lang": "rust",
"repo": "sabikin/Fourier",
"path": "/src/core/log.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sabikin/Fourier path: /src/core/log.rs
use super::typechk::*;
use std::io::{Write, BufWriter};
struct Logger<W: Write> {
out: BufWriter<W>,
does_log: bool,
}
impl<W: Write> Logger<W> {
pub(super) fn new(inner: W) -> Self {
Logger {
out: BufWriter::new(inner),
... | code_fim | medium | {
"lang": "rust",
"repo": "sabikin/Fourier",
"path": "/src/core/log.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn test_option() {
// Trying to be random as possible
let pokemon = vec![
"raichu",
"golem",
"quilava",
"muk",
"wurmple"
];
let first = pokemon.get(0);
println!("0: {:?}", first);
println!("99: {:?}", pokemon.get(99)); // note this does not ... | code_fim | hard | {
"lang": "rust",
"repo": "atskae/learning-rust",
"path": "/hello-world/my-hash-map/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: atskae/learning-rust path: /hello-world/my-hash-map/src/main.rs
use std::collections::HashMap;
fn test_loops() {
let mut counter = 1;
let my_num = loop {
counter += 1;
if counter > 10 {
break counter; // return counter value
}
};
println!("My... | code_fim | hard | {
"lang": "rust",
"repo": "atskae/learning-rust",
"path": "/hello-world/my-hash-map/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Returns the list of events triggered during the execution of the given block.
pub fn get_events_for_block(ctx: &impl ScViewClientContext) -> GetEventsForBlockCall {
let mut f = GetEventsForBlockCall {
func: ScView::new(ctx, HSC_NAME, HVIEW_GET_EVENTS_FOR_BLOCK),
... | code_fim | hard | {
"lang": "rust",
"repo": "iotaledger/wasp",
"path": "/packages/wasmvm/wasmlib/src/coreblocklog/contract.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iotaledger/wasp path: /packages/wasmvm/wasmlib/src/coreblocklog/contract.rs
// Code generated by schema tool; DO NOT EDIT.
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
#![allow(dead_code)]
use crate::*;
use crate::coreblocklog::*;
pub struct ControlAddressesCall<'a>... | code_fim | hard | {
"lang": "rust",
"repo": "iotaledger/wasp",
"path": "/packages/wasmvm/wasmlib/src/coreblocklog/contract.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct IsRequestProcessedCall<'a> {
pub func: ScView<'a>,
pub params: MutableIsRequestProcessedParams,
pub results: ImmutableIsRequestProcessedResults,
}
pub struct ScFuncs {
}
impl ScFuncs {
// Returns the current state controller and governing addresses and at what block index ... | code_fim | hard | {
"lang": "rust",
"repo": "iotaledger/wasp",
"path": "/packages/wasmvm/wasmlib/src/coreblocklog/contract.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut scan = Scanner::default();
let out = &mut BufWriter::new(stdout());
let t:u32 = scan.next();
for _ in 0..t {
let n:usize = scan.next();
let m:usize = scan.next();
let a:Vec<usize> = (0..n).map(|_| scan.next::<usize>() % m).collect();
let mut num:Vec... | code_fim | hard | {
"lang": "rust",
"repo": "Tan-YiFan/Codeforces-Exercises",
"path": "/1497/b/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tan-YiFan/Codeforces-Exercises path: /1497/b/b.rs
/* https://codeforces.com/blog/entry/67391 */
#[allow(unused_imports)]
use std::cmp::{min, max};
use std::io::{BufWriter, stdin, stdout, Write};
#[derive(Default)]
struct Scanner {
buffer: Vec<String>,
}
impl Scanner {
fn next<T: std::st... | code_fim | hard | {
"lang": "rust",
"repo": "Tan-YiFan/Codeforces-Exercises",
"path": "/1497/b/b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(Self {
client: spotify
})
}
pub fn conn(&self) -> &ClientCredsSpotify {
&self.client
}
}<|fim_prefix|>// repo: ajruckman/spotlit-bot path: /src/spotify/mod.rs
use rspotify::{ClientCredsSpotify, Config, Credentials};
pub struct SpotifyClient {
clien... | code_fim | medium | {
"lang": "rust",
"repo": "ajruckman/spotlit-bot",
"path": "/src/spotify/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ajruckman/spotlit-bot path: /src/spotify/mod.rs
use rspotify::{ClientCredsSpotify, Config, Credentials};
<|fim_suffix|> let mut spotify = ClientCredsSpotify::with_config(Credentials::new(&id, &secret), cfg);
spotify.request_token().await?;
Ok(Self {
client: s... | code_fim | hard | {
"lang": "rust",
"repo": "ajruckman/spotlit-bot",
"path": "/src/spotify/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl SpotifyClient {
pub async fn new(id: &str, secret: &str) -> anyhow::Result<Self> {
let mut cfg = Config::default();
cfg.token_refreshing = true;
let mut spotify = ClientCredsSpotify::with_config(Credentials::new(&id, &secret), cfg);
spotify.request_token().await?;... | code_fim | medium | {
"lang": "rust",
"repo": "ajruckman/spotlit-bot",
"path": "/src/spotify/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut man = Man::new();
let mut steps = 0u64;
man.step(&mut gen);
while !(man.x == 0 && man.y == 0) {
man.step(&mut gen);
steps += 1;
}
println!("{}", steps);
}<|fim_prefix|>// repo: tronje/randomg path: /src/main.rs
extern crate randomg;
use randomg::generat... | code_fim | medium | {
"lang": "rust",
"repo": "tronje/randomg",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tronje/randomg path: /src/main.rs
extern crate randomg;
use randomg::generators::Generator;
struct Man {
x: i64,
y: i64,
}
impl Man {
fn new() -> Man {
<|fim_suffix|>fn main() {
let mut gen = randomg::get_generator(randomg::get_seed());
let mut man = Man::new();
let m... | code_fim | hard | {
"lang": "rust",
"repo": "tronje/randomg",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let custom_type = MyCustomLEType::from_le_slice(&[0; size_of::<MyCustomLEType>()]);
println!("{}", custom_type.val);
}<|fim_prefix|>// repo: iCodeIN/Rudra-PoC path: /poc/0116-blockbuffers.rs
/*!
```rudra-poc
[target]
crate = "blockbuffers"
version = "0.1.0"
[report]
[[bugs]]
analyze... | code_fim | medium | {
"lang": "rust",
"repo": "iCodeIN/Rudra-PoC",
"path": "/poc/0116-blockbuffers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/Rudra-PoC path: /poc/0116-blockbuffers.rs
/*!
```rudra-poc
[target]
crate = "blockbuffers"
version = "0.1.0"
[report]
<|fim_suffix|> x
}
}
fn main() {
let custom_type = MyCustomLEType::from_le_slice(&[0; size_of::<MyCustomLEType>()]);
println!("{}", custom_type.val)... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/Rudra-PoC",
"path": "/poc/0116-blockbuffers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> x
}
}
fn main() {
let custom_type = MyCustomLEType::from_le_slice(&[0; size_of::<MyCustomLEType>()]);
println!("{}", custom_type.val);
}<|fim_prefix|>// repo: iCodeIN/Rudra-PoC path: /poc/0116-blockbuffers.rs
/*!
```rudra-poc
[target]
crate = "blockbuffers"
version = "0.1.0"
[report... | code_fim | medium | {
"lang": "rust",
"repo": "iCodeIN/Rudra-PoC",
"path": "/poc/0116-blockbuffers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rusty-desktop/libdrm-rs path: /src/mode_info.rs
// Copyright 2016 The libdrm-rs project developers
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software
// and associated documentation files (the "Software"), to deal in the Software without
// restri... | code_fim | hard | {
"lang": "rust",
"repo": "rusty-desktop/libdrm-rs",
"path": "/src/mode_info.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns pointer to raw C structure.
pub fn as_ptr(&self) -> ffi::xf86drm_mode::drmModeModeInfoPtr {
&self.mode_info
}
}
/// Getters for original members
impl ModeInfo {
#[inline]
pub fn get_clock(&self) -> u32 {
self.mode_info.clock
}
#[inline]
pub fn ... | code_fim | hard | {
"lang": "rust",
"repo": "rusty-desktop/libdrm-rs",
"path": "/src/mode_info.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn build_distance_field_for_arc(size: u32, radius: u32, mode: ArcMode) -> Vec<u8> {
let mut result = Vec::with_capacity((size * size * 4) as usize);
let radius = radius as f32;
for y in 0..size {
for x in 0..size {
let delta = Point2D::new(size - x, size - y);
... | code_fim | hard | {
"lang": "rust",
"repo": "gubaojian/webrast",
"path": "/distance_field.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gubaojian/webrast path: /distance_field.rs
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A very naïve O((width * height)²) implement... | code_fim | hard | {
"lang": "rust",
"repo": "gubaojian/webrast",
"path": "/distance_field.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if min < max {
return Self {
min: min,
max: max,
count_max: count_max,
count_min: count_min,
};
}
panic!("Min can't be larger than min");
}
}
fn main() {
}
#[cfg(test)]
mod tests {
use... | code_fim | hard | {
"lang": "rust",
"repo": "Mutestock/cphsoft",
"path": "/mal/uge02_more/exercise_thing/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mutestock/cphsoft path: /mal/uge02_more/exercise_thing/src/main.rs
trait RealSetTrait {
fn contains(&self, real: f32) -> bool;
fn union(&self, other: RealSet) -> RealSet;
fn difference(&self, other: RealSet) -> RealSet;
fn complement(&self) -> RealSet;
}
struct UnionRealSet {
... | code_fim | hard | {
"lang": "rust",
"repo": "Mutestock/cphsoft",
"path": "/mal/uge02_more/exercise_thing/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if sum < 0 {
println!("Entered the basement: {}", n + 1);
return;
}
},
_ => panic!("Invalid input"),
}
}
panic!("Never went downstairs");
}<|fim_prefix|>// repo: bpglaser/advent path: /2015/src/day01_part... | code_fim | hard | {
"lang": "rust",
"repo": "bpglaser/advent",
"path": "/2015/src/day01_part02/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bpglaser/advent path: /2015/src/day01_part02/src/main.rs
fn main() {
let mut sum: isize = 0;
for (n, c) in std::env::args().skip(1).next().expect("Invalid args").chars()<|fim_suffix|> if sum < 0 {
println!("Entered the basement: {}", n + 1);
re... | code_fim | hard | {
"lang": "rust",
"repo": "bpglaser/advent",
"path": "/2015/src/day01_part02/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NicolasDP/git path: /src/object/date.rs
//! Git date object
extern crate chrono;
use self::chrono::{DateTime, Local, FixedOffset, NaiveDateTime, TimeZone};
use protocol::{Encoder, Decoder};
use std::{fmt, str, io};
use nom;
/// Git date object
///
/// Based on the [chrono](https://crates.io/c... | code_fim | hard | {
"lang": "rust",
"repo": "NicolasDP/git",
"path": "/src/object/date.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// encode in a string for the git object format
///
/// i.e.: Seconds since EPOCH followed by timezone (`+/-HHMM`).
///
/// ```
/// use git::object::Date;
///
/// let date = Date::ymd_hms(2016, 11, 24, 7, 39, 35)
/// .expect("to have a valid date and time");... | code_fim | hard | {
"lang": "rust",
"repo": "NicolasDP/git",
"path": "/src/object/date.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug,Clap)]
pub struct Car {
#[clap(short, long)]
pub id : u64,
#[clap(short, long)]
pub make : String
}<|fim_prefix|>// repo: itzcookiie/rust-y-code path: /tasks/src/lib.rs
use clap::Clap;
#[macro_use]
extern crate task_macro;
<|fim_middle|>#[derive(PrintStruct)]
pub struct T... | code_fim | medium | {
"lang": "rust",
"repo": "itzcookiie/rust-y-code",
"path": "/tasks/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: itzcookiie/rust-y-code path: /tasks/src/lib.rs
use clap::Clap;
#[macro_use]
extern crate task_macro;
<|fim_suffix|>#[derive(Debug,Clap)]
pub struct Car {
#[clap(short, long)]
pub id : u64,
#[clap(short, long)]
pub make : String
}<|fim_middle|>#[derive(PrintStruct)]
pub struct T... | code_fim | medium | {
"lang": "rust",
"repo": "itzcookiie/rust-y-code",
"path": "/tasks/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fabienjuif/gitmoji-changelog-rust path: /src/group.rs
use std::cmp::Ordering;
use std::collections::HashMap;
use crate::commit::Commit;
lazy_static! {
static ref GROUPS: Vec<Group> = {
let mut groups = vec![];
groups.push(Group::new(
"Added",
10,
... | code_fim | hard | {
"lang": "rust",
"repo": "fabienjuif/gitmoji-changelog-rust",
"path": "/src/group.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.order.cmp(&other.order)
}
}
impl PartialOrd for Group {
fn partial_cmp(&self, other: &Group) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Group {
pub fn new(name: &'static str, order: usize, codes: Vec<&'static str>) -> Group {
Group {
ord... | code_fim | hard | {
"lang": "rust",
"repo": "fabienjuif/gitmoji-changelog-rust",
"path": "/src/group.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lol3rrr/stream-httparse path: /src/streaming_parser/resp_parser.rs
Error;
use crate::{header::HeaderKey, Headers, Response, StatusCode};
type ProtocolState = (usize, usize);
type StatusCodeState = (usize, usize);
type HeaderKeyState = (usize, usize);
enum ParseState {
Nothing,
Protocol... | code_fim | hard | {
"lang": "rust",
"repo": "Lol3rrr/stream-httparse",
"path": "/src/streaming_parser/resp_parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let chunk_size = bytes.len();
if left_to_read >= chunk_size {
self.body_buffer.extend_from_slice(bytes);
(self.body_buffer.len() == length, 0)
} else {
self.body_buffer.extend_from_slice(&bytes[..le... | code_fim | hard | {
"lang": "rust",
"repo": "Lol3rrr/stream-httparse",
"path": "/src/streaming_parser/resp_parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lol3rrr/stream-httparse path: /src/streaming_parser/resp_parser.rs
usize, usize);
type StatusCodeState = (usize, usize);
type HeaderKeyState = (usize, usize);
enum ParseState {
Nothing,
ProtocolParsed(ProtocolState),
HeaderKey(ProtocolState, StatusCodeState, usize),
HeaderValue(... | code_fim | hard | {
"lang": "rust",
"repo": "Lol3rrr/stream-httparse",
"path": "/src/streaming_parser/resp_parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
let commit_begin = Instant::now();
if self.dirty.fetch_and(false, Ordering::SeqCst) {
let mut writer = self.finalize();
match writer.commit() {
Ok(_) => (),
Err(error) => log::error!("cannot comm... | code_fim | hard | {
"lang": "rust",
"repo": "binier/tezedge-debugger",
"path": "/tezedge-recorder/src/database/search.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: binier/tezedge-debugger path: /tezedge-recorder/src/database/search.rs
use std::{
fs,
ops::DerefMut,
path::Path,
sync::{
Arc, Mutex, MutexGuard, TryLockError,
atomic::{Ordering, AtomicBool},
},
thread,
};
use tantivy::{
directory::MmapDirectory, schema... | code_fim | hard | {
"lang": "rust",
"repo": "binier/tezedge-debugger",
"path": "/tezedge-recorder/src/database/search.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn read(
&self,
query: &str,
limit: usize,
) -> Result<impl Iterator<Item = (f32, u64)>, TantivyError> {
let reader = self
.index
.reader_builder()
.reload_policy(ReloadPolicy::OnCommit)
.try_into()?;
let s... | code_fim | hard | {
"lang": "rust",
"repo": "binier/tezedge-debugger",
"path": "/tezedge-recorder/src/database/search.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn usize_read(&mut self) -> usize {
self.read()
}
fn read<T>(&mut self) -> T
where
T: std::str::FromStr,
T::Err: std::fmt::Debug,
{
let mut b = self.byte();
while Scanner::is_space(b) {
b = self.byte();
}
for pos in ... | code_fim | hard | {
"lang": "rust",
"repo": "AndrewMendezLacambra/rust-programming-contest-solutions",
"path": "/atcoder/arc099_c.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AndrewMendezLacambra/rust-programming-contest-solutions path: /atcoder/arc099_c.rs
use std::cmp;
fn main() {
let mut sc = Scanner::new();
let n = sc.read();
let m = sc.read();
let mut inverted_graph = vec![vec![true; n]; n];
for _ in 0..m {
let a = sc.usize_read() - ... | code_fim | hard | {
"lang": "rust",
"repo": "AndrewMendezLacambra/rust-programming-contest-solutions",
"path": "/atcoder/arc099_c.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sulanov/locomix path: /src/pga2311.rs
use self::rppal::spi;
use crate::base::*;
use crate::volume_device;
use rppal;
use toml;
pub struct Pga2311Volume {
device: spi::Spi,
}
impl From<spi::Error> for Error {
fn from(e: spi::Error) -> Error {
Error::from_string(format!("spi erro... | code_fim | medium | {
"lang": "rust",
"repo": "sulanov/locomix",
"path": "/src/pga2311.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Pga2311Volume {
pub fn new(bus: spi::Bus, slave: spi::SlaveSelect) -> Result<Pga2311Volume> {
let device = spi::Spi::new(bus, slave, SPI_FREQUENCY_HZ, spi::Mode::Mode0)?;
Ok(Pga2311Volume { device })
}
pub fn create_from_config(
config: &toml::value::Table,
) ... | code_fim | hard | {
"lang": "rust",
"repo": "sulanov/locomix",
"path": "/src/pga2311.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>const fn to_nonzero(n: Option<u32>) -> Option<NonZeroU32> {
// Can be replaced with `n.and_then(NonZeroU32::new)` if that is ever usable
// in const context. Requires https://github.com/rust-lang/rfcs/pull/2632.
match n {
None => None,
Some(n) => NonZeroU32::new(n),
}
}<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "intellij-rust/intellij-rust",
"path": "/attributes-info/rustc_feature/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: intellij-rust/intellij-rust path: /attributes-info/rustc_feature/src/lib.rs
#![feature(lazy_cell)]
use std::fmt;
use std::num::NonZeroU32;
pub use accepted::ACCEPTED_FEATURES;
pub use active::{ACTIVE_FEATURES, Features, INCOMPATIBLE_FEATURES};
pub use builtin_attrs::{
AttributeGate, Attrib... | code_fim | hard | {
"lang": "rust",
"repo": "intellij-rust/intellij-rust",
"path": "/attributes-info/rustc_feature/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>:{colors, default_theme, fonts, light_theme, vector_graphics::material_font_icons};
pub use utils::*;<|fim_prefix|>// repo: ChayimFriedman2/orbtk path: /crates/widgets/src/prelude.rs
pub use std::{
any::{Any, TypeId},
cell::RefCell,
collections::{HashMap, HashSet},
fm<|fim_middle|>t::Debu... | code_fim | hard | {
"lang": "rust",
"repo": "ChayimFriedman2/orbtk",
"path": "/crates/widgets/src/prelude.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ChayimFriedman2/orbtk path: /crates/widgets/src/prelude.rs
pub use std::{
any::{Any, TypeId},
cell::RefCell,
collections::{HashMap, HashSet},
fm<|fim_suffix|>:{colors, default_theme, fonts, light_theme, vector_graphics::material_font_icons};
pub use utils::*;<|fim_middle|>t::Debu... | code_fim | hard | {
"lang": "rust",
"repo": "ChayimFriedman2/orbtk",
"path": "/crates/widgets/src/prelude.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut src : Vec<usize> = (0..2000000).collect();
let mut rng = thread_rng();
src.shuffle(&mut rng);
src
}
fn sort(c: &mut Criterion) {
let algos = vec!["merge", "quick"];
for x in algos {
c.bench_function(&x, move |b| {
b.iter_batched(|| get_data(), |data| so... | code_fim | medium | {
"lang": "rust",
"repo": "waalge/sorting",
"path": "/benches/sort.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: waalge/sorting path: /benches/sort.rs
use criterion::{criterion_group, criterion_main, Criterion, BatchSize};
use rand::{thread_rng, seq::SliceRandom};
use sorting::sort;
fn get_data() -> Vec<usize> {
let mut src : Vec<usize> = (0..2000000).collect();
let mut rng = thread_rng();
sr... | code_fim | medium | {
"lang": "rust",
"repo": "waalge/sorting",
"path": "/benches/sort.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn make_merkle_hash(vtxs: &Vec<transaction::Transaction>) -> [u8; 32] {
if vtxs.len() == 0 {
return [0; 32];
}
let mut vec_merkle_tree: Vec<[u8; 32]> = Vec::new();
for tx in vtxs.iter() {
vec_merkle_tree.push(tx.hash);
}
let mut... | code_fim | hard | {
"lang": "rust",
"repo": "rust-chainblock/blockchain_Rust3",
"path": "/core/src/block.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while size > 1 {
let mut i: u64 = 0;
let temp_size = size as u64;
while i < temp_size {
let i2 = Block::min(i + 1, temp_size - 1);
let index1: usize = (j + i) as usize;
let index2: usize = (j + i2) as usize;
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-chainblock/blockchain_Rust3",
"path": "/core/src/block.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-chainblock/blockchain_Rust3 path: /core/src/block.rs
use chrono::prelude::*;
use utils::coder;
use serde::{Deserialize, Serialize};
use crate::transaction;
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct BlockHeader {
pub time: i64,
//transactions data mer... | code_fim | hard | {
"lang": "rust",
"repo": "rust-chainblock/blockchain_Rust3",
"path": "/core/src/block.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>r
}
}
/// Returns the bigger of two 64-bit floating point numbers.
///
/// If one of the arguments is NaN, the other argument is returned.
/// If both arguments are NaN, NaN is returned.
#[no_mangle]
#[inline]
pub extern "C" fn fmax(l: f64, r: f64) -> f64 {
if l >= r || r.is_nan() {
l
... | code_fim | medium | {
"lang": "rust",
"repo": "nagisa/math.rs",
"path": "/src/max.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nagisa/math.rs path: /src/max.rs
use utils::Float;
/// Returns the bigger of two 32-bit floating point numbers.
///
/// If one of the arguments is NaN, the other argument is returned.
/// If both ar<|fim_suffix|>are NaN, NaN is returned.
#[no_mangle]
#[inline]
pub extern "C" fn fmax(l: f64, r: ... | code_fim | hard | {
"lang": "rust",
"repo": "nagisa/math.rs",
"path": "/src/max.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for j in (0..IMG_HEIGHT).rev() {
eprintln!("\rScanlines remaining: {}", j);
for i in 0..IMG_WIDTH {
let mut c: Color3 = Color3::new(0.0, 0.0, 0.0);
for _ in 0..SAMPLES_PER_PIXEL {
let u: f64 = (f64::from(i) + rng.gen::<f64>())/f64::from(IMG_WIDTH... | code_fim | medium | {
"lang": "rust",
"repo": "jediahkatz/raytracer-in-one-weekend",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Image
const ASPECT_RATIO: f64 = 16.0 / 9.0;
const IMG_WIDTH: i32 = 400;
const IMG_HEIGHT: i32 = ((IMG_WIDTH as f64) / ASPECT_RATIO) as i32;
const SAMPLES_PER_PIXEL: i32 = 100;
const MAX_DEPTH: i32 = 50;
// World
let mat_ground = Lambertian::new(Color3::new(0.8, 0.8, 0.0... | code_fim | medium | {
"lang": "rust",
"repo": "jediahkatz/raytracer-in-one-weekend",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jediahkatz/raytracer-in-one-weekend path: /src/main.rs
mod vec3;
mod ray;
mod hittable;
mod material;
mod camera;
use vec3::{Color3, Point3, Vec3};
use ray::Ray;
use hittable::{Object, Sphere};
use material::{Lambertian, Metal};
use camera::Camera;
use rand::Rng;
fn main() {
<|fim_suffix|> f... | code_fim | hard | {
"lang": "rust",
"repo": "jediahkatz/raytracer-in-one-weekend",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: keithnoguchi/chat path: /src/main.rs
//! chat server
use async_std::{
net::{TcpListener, TcpStream, ToSocketAddrs},
sync::Arc,
task::{self, TaskId},
};
use futures_channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender};
use futures_util::{
io::{AsyncBufReadExt, AsyncWrite... | code_fim | hard | {
"lang": "rust",
"repo": "keithnoguchi/chat",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn reader(mut broker: Sender<Event>, stream: TcpStream) -> Result<()> {
let id = task::current().id();
let stream = Arc::new(stream);
broker.send(Event::Join(id, Arc::clone(&stream))).await?;
let mut reader = BufReader::new(&*stream).lines();
while let Some(line) = reader.next().... | code_fim | hard | {
"lang": "rust",
"repo": "keithnoguchi/chat",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NNemec/azul path: /azulc/src/main.rs
extern crate azulc_lib;
extern crate azul_core;
use std::env;
use std::fs;
use std::path::Path;
use std::process::exit;
use azul_core::{
gl::OptionGlContextPtr,
window::FullWindowState,
xml::{XmlComponentMap, XmlNode},
window::LogicalSize,
... | code_fim | hard | {
"lang": "rust",
"repo": "NNemec/azul",
"path": "/azulc/src/main.rs",
"mode": "psm",
"license": "MPL-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn process(action: Action, file: Option<&String>) {
use azul_core::xml::*;
use azulc_lib::xml::parse_xml_string;
if action == Action::PrintHelp {
print_help();
exit(0);
}
let input_file = match file {
Some(s) => s,
None => {
eprintln!("error:... | code_fim | hard | {
"lang": "rust",
"repo": "NNemec/azul",
"path": "/azulc/src/main.rs",
"mode": "spm",
"license": "MPL-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let parent_node_id = match node_id.into_crate_internal() { Some(s) => s, None => continue, };
let tabs = " ".repeat(*depth);
let width = result.width_calculated_rects.as_ref()[parent_node_id];
let height = result.height_calculated_rects.as_ref()[parent_node_id];
... | code_fim | hard | {
"lang": "rust",
"repo": "NNemec/azul",
"path": "/azulc/src/main.rs",
"mode": "spm",
"license": "MPL-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Get a handle to the deployment.
let client = match Client::with_options(client_options) {
Ok(c) => c,
Err(e) => panic!("Client Creation Failed: {}", e),
};
let engine = State {
client: Arc::new(client),
};
let mut ... | code_fim | hard | {
"lang": "rust",
"repo": "roche-rs/mongodb",
"path": "/image/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: roche-rs/mongodb path: /image/src/main.rs
use async_mongodb_session::MongodbSessionStore;
use async_std::sync::Arc;
use async_std::task;
use dotenv::dotenv;
use mongodb::{options::ClientOptions, Client};
use std::env;
mod functions;
#[derive(Clone, Debug)]
pub struct State {
client: Arc<Cl... | code_fim | medium | {
"lang": "rust",
"repo": "roche-rs/mongodb",
"path": "/image/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let engine = State {
client: Arc::new(client),
};
let mut app = tide::with_state(engine);
app.with(tide::sessions::SessionMiddleware::new(
MongodbSessionStore::new(&mongodb_conn.as_str(), "async-mongodb", "tide-sessions").await?,
std::env... | code_fim | hard | {
"lang": "rust",
"repo": "roche-rs/mongodb",
"path": "/image/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rforcen/rust path: /line_graphs/src/main.rs
#![allow(dead_code)]
mod spiral;
use crate::spiral::*;
mod harmonigraph3d;
use crate::harmonigraph3d::*;
mod harmonigraph;
use crate::harmonigraph::*;
mod lissajous;
use lissajous::*;
mod color_interp;
mod music_freq;
use kiss3d::window::Window;
fn... | code_fim | hard | {
"lang": "rust",
"repo": "rforcen/rust",
"path": "/line_graphs/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn do_hg3d() {
let mut window = Window::new("harmonigraph 3d");
let mut hg3d = HarmoniGraph3D::new().with_preset(4).with_scale(0.25);
while window.render() {
for line in &mut hg3d.generate_lines().windows(2) {
window.draw_line(&line[0].0, &line[1].0, &line[0].1);
}... | code_fim | hard | {
"lang": "rust",
"repo": "rforcen/rust",
"path": "/line_graphs/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn preflight_compares_headers_against_allowed_headers() -> TestResult {
let cfg = CorsBuilder::new()
.allow_origins(AllowedOrigins::Any { allow_null: false })
.allow_methods(vec![Method::POST])
.allow_headers(&[
header::SERVER,
... | code_fim | hard | {
"lang": "rust",
"repo": "dora-gt/tower-web",
"path": "/src/middleware/cors/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dora-gt/tower-web path: /src/middleware/cors/config.rs
}
}
impl CorsResource {
fn into_simple(self) -> TestResult<HeaderMap> {
match self {
CorsResource::Simple(h) => Ok(h),
_ => Err("Not a simple resource".into()),
}
... | code_fim | hard | {
"lang": "rust",
"repo": "dora-gt/tower-web",
"path": "/src/middleware/cors/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> macro_rules! assert_variant {
($value:expr, $var:pat) => {
match $value {
$var => {}
_ => assert!(
false,
"Expected variant {}, was {:?}",
stringify!($var),
$value
... | code_fim | hard | {
"lang": "rust",
"repo": "dora-gt/tower-web",
"path": "/src/middleware/cors/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.chip8.update_timers();
if self.chip8.graphics_needs_refresh() {
self.hardware
.refresh_graphics(self.chip8.graphics(), self.chip8.resolution_scale())?;
self.chip8.graphics_clear_refresh();
}
if self.chip8.audio_sound() {
... | code_fim | hard | {
"lang": "rust",
"repo": "ali-graham/chipper",
"path": "/src/emulator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // fn tick_step(&mut self) -> Option<Action> {
// for _cycles in 0u8..8u8 {
// // actually 83 cycles / 10 ticks
// self.chip8.emulate_cycle();
// // TODO block waiting for ADVANCE event
// }
// None
// }
fn refresh(&mut self) -> Res... | code_fim | hard | {
"lang": "rust",
"repo": "ali-graham/chipper",
"path": "/src/emulator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ali-graham/chipper path: /src/emulator.rs
use std::fs::File;
use std::io::Read;
use std::thread;
use std::time::Duration;
use std::time::Instant;
use anyhow::Context;
use anyhow::Result;
use crate::chip8;
use crate::hardware::Hardware;
use crate::profile;
use crate::Action;
use crate::KeyMappi... | code_fim | hard | {
"lang": "rust",
"repo": "ali-graham/chipper",
"path": "/src/emulator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod integer;
mod error;
mod wrapint;
pub use integer::parse_integer;
pub use error::Error;
pub use wrapint::Int;
/// Numeric suffixes supported by the library
pub const NUMERIC_SUFFIXES: &'static [(&'static str, u64)] = &[
("k", 1000),
("M", 1000_000),
("G", 1000_000_000),
("ki", 1024),
... | code_fim | medium | {
"lang": "rust",
"repo": "tailhook/humannum",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use integer::parse_integer;
pub use error::Error;
pub use wrapint::Int;
/// Numeric suffixes supported by the library
pub const NUMERIC_SUFFIXES: &'static [(&'static str, u64)] = &[
("k", 1000),
("M", 1000_000),
("G", 1000_000_000),
("ki", 1024),
("Mi", 1048576),
("Gi", 1024*1... | code_fim | medium | {
"lang": "rust",
"repo": "tailhook/humannum",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tailhook/humannum path: /src/lib.rs
//! Human-friendly number parser
//!
//! Currently this only currently implements parsing of integers.
//!
//! The format of values accepted is described in docstring
//! of `parse_integer`.
//!
//! # Example (Functional)
//!
//! ```
//! use humannum::parse_in... | code_fim | medium | {
"lang": "rust",
"repo": "tailhook/humannum",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@lib.check_number(rezult,30)@
@/repeat@<|fim_prefix|>// repo: bradunov/shkola path: /questions/fractions/q00076/text.rs
Izrazi razlomak decimalnim brojem.
@repeat(5)@
@center@ \(\frac{@brojilac@}{@i<|fim_middle|>menilac@}\) @hspacept(3)@ = @hspacept(3)@ | code_fim | easy | {
"lang": "rust",
"repo": "bradunov/shkola",
"path": "/questions/fractions/q00076/text.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bradunov/shkola path: /questions/fractions/q00076/text.rs
Izrazi razlomak decimalnim brojem.
@rep<|fim_suffix|>@lib.check_number(rezult,30)@
@/repeat@<|fim_middle|>eat(5)@
@center@ \(\frac{@brojilac@}{@imenilac@}\) @hspacept(3)@ = @hspacept(3)@ | code_fim | medium | {
"lang": "rust",
"repo": "bradunov/shkola",
"path": "/questions/fractions/q00076/text.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: trembel/ambiq-apollo3p-pac path: /src/gpio/padregr.rs
ks if the value of the field is `LOW`"]
#[inline(always)]
pub fn is_low(&self) -> bool {
*self == PAD70STRNG_A::LOW
}
#[doc = "Checks if the value of the field is `HIGH`"]
#[inline(always)]
pub fn is_high(&self... | code_fim | hard | {
"lang": "rust",
"repo": "trembel/ambiq-apollo3p-pac",
"path": "/src/gpio/padregr.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as _
}
}
#[doc = "Reader of field `PAD68FNCSEL`"]
pub type PAD68FNCSEL_R = crate::R<u8, PAD68FNCSEL_A>;
impl PAD68FNCSEL_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<u8, PAD68FNCSEL_A> {
use crate::Variant::... | code_fim | hard | {
"lang": "rust",
"repo": "trembel/ambiq-apollo3p-pac",
"path": "/src/gpio/padregr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.