text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>iant
:
&
'
static
str
len
:
usize
)
-
>
Result
<
Self
:
:
SerializeTupleVariant
Error
>
{
Ok
(
SerializeTupleVariant
{
name
:
String
:
:
from
(
variant
)
vec
:
Vec
:
:
with_capacity
(
len
)
}
)
}
fn
serialize_map
(
self
_len
:
Option
<
usize
>
)
-
>
Result
<
Self
:
:
SerializeMap
Error
>
{
Ok
(
SerializeM... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/serde_cbor/src/value/ser.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/serde_cbor/src/value/ser.rs
/
/
Copyright
2017
Serde
Developers
/
/
/
/
Licensed
under
the
Apache
License
Version
2
.
0
<
LICENSE
-
APACHE
or
/
/
http
:
/
/
www
.
apache
.
org
/
licenses
/
LICENSE
-
2
.
0
>
or
the
MIT
license
/
/
<
LICENSE
-
MI... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/serde_cbor/src/value/ser.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> HttpServer::new(move || {
App::new()
.wrap(Logger::default())
.service(web::resource("/problems").route(web::post().to(problem::solution)))
})
.bind("127.0.0.1:8000")?
.run()
.await
}<|fim_prefix|>// repo: reinterpretcat/vrp-experiments path: /server-k8... | code_fim | medium | {
"lang": "rust",
"repo": "reinterpretcat/vrp-experiments",
"path": "/server-k8s-api/server/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reinterpretcat/vrp-experiments path: /server-k8s-api/server/src/main.rs
use actix_web::{middleware::Logger, web, App, HttpServer};
mod problem;
<|fim_suffix|> HttpServer::new(move || {
App::new()
.wrap(Logger::default())
.service(web::resource("/problems").ro... | code_fim | medium | {
"lang": "rust",
"repo": "reinterpretcat/vrp-experiments",
"path": "/server-k8s-api/server/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: x87-va/rusty_melody_bot path: /src/config.rs
use std::fs;
use std::path::Path;
use std::io::prelude::*;
use super::toml;
use super::errors::{Result, ResultExt, ErrorKind};
<|fim_suffix|>#[derive(Debug, Clone, Deserialize)]
pub struct Telegram {
pub token: String
}
#[derive(Debug, Clone,... | code_fim | medium | {
"lang": "rust",
"repo": "x87-va/rusty_melody_bot",
"path": "/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut content = String::new();
config_file.read_to_string(&mut content).chain_err(|| {
ErrorKind::Config(path.to_string_lossy().into_owned(), "Error in reading file")
})?;
let app_confg: AppConfig = toml::from_str(&content).chain_err(|| {
ErrorKind::Config(path.t... | code_fim | hard | {
"lang": "rust",
"repo": "x87-va/rusty_melody_bot",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn build_unicode_mapping(
ident: &Ident,
names: &[String],
glyph_list: &[(String, Vec<char>)],
) -> Result<proc_macro2::TokenStream, Box<dyn Error>> {
let mut match_clauses = vec![];
for (glyph_name, unicode_values) in glyph_list {
if let Some(index) = names.iter().position(|na... | code_fim | hard | {
"lang": "rust",
"repo": "manuel-rhdt/lemon_pdf",
"path": "/build.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: manuel-rhdt/lemon_pdf path: /build.rs
use afm;
use glob::glob;
use pom;
use proc_macro2::{Ident, Span};
use quote::quote;
use std::error::Error;
use std::io::Write;
use std::path::Path;
use std::{char, u32};
use std::{env, fs};
use inflector::cases::pascalcase::to_pascal_case;
use inflector::c... | code_fim | hard | {
"lang": "rust",
"repo": "manuel-rhdt/lemon_pdf",
"path": "/build.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match unicode {
#(#match_clauses),*,
_ => None
}
}
})
}
fn build_glyph_list(filename: &str) -> Result<Vec<(String, Vec<char>)>, std::io::Error> {
let mut reader = csv::ReaderBuilder::new()
.comment(Some(b'#'))
.delimi... | code_fim | hard | {
"lang": "rust",
"repo": "manuel-rhdt/lemon_pdf",
"path": "/build.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
/// A trait for a device that can change its baudrate
pub trait ReconfigurableBaudrate {
fn change_baudrate<CLOCK, FREQ>(&mut self, clock: CLOCK, freq: FREQ)
where CLOCK: Into<Hertz>,
FREQ: Into<Hertz>;
}<|fim_prefix|>// repo: mvniekerk/atsamd path: /hal/src/common/sercom_trait... | code_fim | medium | {
"lang": "rust",
"repo": "mvniekerk/atsamd",
"path": "/hal/src/common/sercom_traits.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mvniekerk/atsamd path: /hal/src/common/sercom_traits.rs
use crate::hal::spi::Mode;
use crate::time::Hertz;
/// A trait for an SPI device that can change its CPOL and CPHA mode
pub trait ReconfigurableSpiMode {
fn change_spi_mode(&mut self, mode: Mode);
}
<|fim_suffix|> where CLOCK: ... | code_fim | medium | {
"lang": "rust",
"repo": "mvniekerk/atsamd",
"path": "/hal/src/common/sercom_traits.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Convenience function for calling the g-code crate's PEG parser with user-defined g-code.
fn parse_snippet(gcode: &'_ String) -> Result<Snippet<'_>, ParseError> {
snippet_parser(gcode)
}
/// Write GCode tokens to a byte sink in a nicely formatted manner
fn tokens_into_gcode_bytes<W: std::io::Write... | code_fim | hard | {
"lang": "rust",
"repo": "VB6Hobbyst7/svg2gcode-1",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VB6Hobbyst7/svg2gcode-1 path: /src/main.rs
#[macro_use]
extern crate log;
use std::env;
use std::fs::File;
use std::io::{self, Read};
use std::path::PathBuf;
use g_code::parse::{ast::Snippet, snippet_parser, ParseError};
use structopt::StructOpt;
/// Converts an SVG to GCode in an internal re... | code_fim | hard | {
"lang": "rust",
"repo": "VB6Hobbyst7/svg2gcode-1",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut turtle = Turtle::new(machine);
let mut program = converter::svg2program(&document, options, &mut turtle);
postprocess::set_origin(&mut program, lyon_geom::point(0., 0.));
let mut actual = vec![];
assert!(tokens_into_gcode_bytes(&program, &mut actual).is_ok(... | code_fim | hard | {
"lang": "rust",
"repo": "VB6Hobbyst7/svg2gcode-1",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Delete file-tags from the database
pub fn delete_ids(pairs: &Vec<(i64, i64)>, c: &db::Connection) -> Res<usize> {
Ok(diesel::delete(file_tags::table.filter(Self::with_pairs(pairs, true))).execute(c.get())?)
}
}
use core::fmt::{Display, Formatter, Error as FmtError};
impl Display f... | code_fim | hard | {
"lang": "rust",
"repo": "4nickel/tag-suite",
"path": "/src/model/file_tag.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 4nickel/tag-suite path: /src/model/file_tag.rs
use diesel::{dsl::*, query_builder::{BoxedSelectStatement}, query_source::joins::{JoinOn, Join, Inner}};
use diesel::{expression::{SqlLiteral, BoxableExpression}, sqlite::Sqlite, sql_types::{Bool, BigInt}};
use crate::{model::export::*, util::{sql}}... | code_fim | hard | {
"lang": "rust",
"repo": "4nickel/tag-suite",
"path": "/src/model/file_tag.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The first epoch in the next proving period.
pub fn next_period_start(&self) -> ChainEpoch {
self.period_start + self.w_post_proving_period
}
/// Whether the current deadline is currently open.
pub fn is_open(&self) -> bool {
self.current_epoch >= self.open && self.... | code_fim | hard | {
"lang": "rust",
"repo": "creativcoder/forest",
"path": "/types/src/deadlines/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: creativcoder/forest path: /types/src/deadlines/mod.rs
// Copyright 2020 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
mod quantize;
pub use self::quantize::*;
use clock::ChainEpoch;
use serde::{Deserialize, Serialize};
/// Deadline calculations with respect to a current epoch.... | code_fim | hard | {
"lang": "rust",
"repo": "creativcoder/forest",
"path": "/types/src/deadlines/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns the next instance of this deadline that has not yet elapsed.
pub fn next_not_elapsed(self) -> Self {
std::iter::successors(Some(self), |info| {
Some(Self::new(
info.next_period_start(),
info.index,
info.current_epoch,
... | code_fim | hard | {
"lang": "rust",
"repo": "creativcoder/forest",
"path": "/types/src/deadlines/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: argmin-rs/argmin path: /argmin/src/core/state/linearprogramstate.rs
self.param = Some(param);
self
}
/// Set target cost.
///
/// When this cost is reached, the algorithm will stop. The default is
/// `Self::Float::NEG_INFINITY`.
///
/// # Example
///... | code_fim | hard | {
"lang": "rust",
"repo": "argmin-rs/argmin",
"path": "/argmin/src/core/state/linearprogramstate.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Checks if the current parameter vector is better than the previous best parameter value. If
/// a new best parameter vector was found, the state is updated accordingly.
///
/// # Example
///
/// ```
/// # use argmin::core::{LinearProgramState, State, ArgminFloat};
/// l... | code_fim | hard | {
"lang": "rust",
"repo": "argmin-rs/argmin",
"path": "/argmin/src/core/state/linearprogramstate.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: argmin-rs/argmin path: /argmin/src/core/state/linearprogramstate.rs
, State};
/// # let state: LinearProgramState<Vec<f64>, f64> = LinearProgramState::new();
/// # let cost_old = 1.0f64;
/// # let state = state.cost(cost_old);
/// # assert_eq!(state.prev_cost.to_ne_bytes(), f64::... | code_fim | hard | {
"lang": "rust",
"repo": "argmin-rs/argmin",
"path": "/argmin/src/core/state/linearprogramstate.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rune-rs/rune path: /crates/rune/src/ast/expr_if.rs
use crate::ast::prelude::*;
#[test]
fn ast_parse() {
use crate::testing::rt;
rt::<ast::ExprIf>("if 0 { }");
rt::<ast::ExprIf>("if 0 { } else { }");
rt::<ast::ExprIf>("if 0 { } else if 0 { } else { }");
rt::<ast::ExprI... | code_fim | hard | {
"lang": "rust",
"repo": "rune-rs/rune",
"path": "/crates/rune/src/ast/expr_if.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// An else branch of an if expression.
#[derive(Debug, Clone, PartialEq, Eq, ToTokens, Parse, Spanned)]
#[non_exhaustive]
pub struct ExprElse {
/// The `else` token.
pub else_: T![else],
/// The body of the else statement.
pub block: Box<ast::Block>,
}
impl Peek for ExprElse {
fn pee... | code_fim | hard | {
"lang": "rust",
"repo": "rune-rs/rune",
"path": "/crates/rune/src/ast/expr_if.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: boardwalk/foundationdb2-rs path: /foundationdb/src/transaction.rs
use crate::error::Error;
use crate::future::Future;
use crate::options::{ConflictRangeType, MutationType, StreamingMode, TransactionOption};
use crate::outputs::{Key, KeyValueArray, StringArray, Value};
use foundationdb_sys as fdb... | code_fim | hard | {
"lang": "rust",
"repo": "boardwalk/foundationdb2-rs",
"path": "/foundationdb/src/transaction.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !self.tran.is_null() {
unsafe { fdb::fdb_transaction_destroy(self.tran) };
}
}
}
/*
* CommittedTransaction
*/
pub struct CommittedTransaction {
pub(crate) tran: *mut fdb::FDBTransaction,
}
impl CommittedTransaction {
pub fn get_committed_version(&self) -> Re... | code_fim | hard | {
"lang": "rust",
"repo": "boardwalk/foundationdb2-rs",
"path": "/foundationdb/src/transaction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut temp = [0u8; 4];
// The first round key is the key itself.
for i in 0..NK as usize {
round_key[(i * 4)] = key[(i * 4)];
round_key[(i * 4) + 1] = key[(i * 4) + 1];
round_key[(i * 4) + 2] = key[(i * 4) + 2];
round_key[(i * 4) + 3] = key[(i * 4) + 3];
... | code_fim | hard | {
"lang": "rust",
"repo": "AtaraxiaSjel/small_aes_rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AtaraxiaSjel/small_aes_rs path: /src/lib.rs
, 0x19, 0x73,
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5... | code_fim | hard | {
"lang": "rust",
"repo": "AtaraxiaSjel/small_aes_rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AtaraxiaSjel/small_aes_rs path: /src/lib.rs
let encrypted_block = self.aes_cbc_encrypt_block(block);
block = [0u8; AES_BLOCKLEN];
writer.write_all(&encrypted_block)?;
}
Ok(())
}
/// Decrypt buffer without trim trailing zeros
pub fn aes_cbc_d... | code_fim | hard | {
"lang": "rust",
"repo": "AtaraxiaSjel/small_aes_rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get the given passive element, if it exists.
pub fn get_passive_element(&self, index: ElemIndex) -> Option<&[FunctionIndex]> {
self.passive_elements.get(&index).map(|es| &**es)
}
/// Get the exported signatures of the module
pub fn exported_signatures(&self) -> Vec<Functio... | code_fim | hard | {
"lang": "rust",
"repo": "libonomy/libo-wasmer",
"path": "/lib/vm/src/module.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: libonomy/libo-wasmer path: /lib/vm/src/module.rs
om/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md
//! Data structure for representing WebAssembly modules
//! in a [`Module`].
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt;
use std::iter::... | code_fim | hard | {
"lang": "rust",
"repo": "libonomy/libo-wasmer",
"path": "/lib/vm/src/module.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: libonomy/libo-wasmer path: /lib/vm/src/module.rs
[`Module`].
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt;
use std::iter::ExactSizeIterator;
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
use std::sync::Arc;
use wasmer_types::... | code_fim | hard | {
"lang": "rust",
"repo": "libonomy/libo-wasmer",
"path": "/lib/vm/src/module.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let path = format!("{}{}", env!("CARGO_MANIFEST_DIR"), pda_path);
let config = parser::Config { filename: path };
let cfg = parser::run(config).unwrap();
let path_expected = format!("{}{}", env!("CARGO_MANIFEST_DIR"), cfg_path);
let expected_result = fs::read_to_s... | code_fim | medium | {
"lang": "rust",
"repo": "ZeWaka/pda2cfg",
"path": "/src/test.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_conversion_1() {
test_conversion("/tests/test.pda", "/tests/test.cfg");
}
#[test]
fn test_conversion_2() {
test_conversion("/tests/test2.pda", "/tests/test2.cfg");
}
#[test]
fn test_conversion_3_fail() {
test_conversion("/tests/test3.... | code_fim | medium | {
"lang": "rust",
"repo": "ZeWaka/pda2cfg",
"path": "/src/test.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZeWaka/pda2cfg path: /src/test.rs
#[cfg(test)]
mod tests {
use crate::lib::parser;
use crate::lib::pda;
use std::fs;
#[test]
fn test_pda_creation() {
let mut pda = pda::PDA::build();
pda.set_start("foo".into());
assert_eq!(pda.start_state, "foo".to_st... | code_fim | hard | {
"lang": "rust",
"repo": "ZeWaka/pda2cfg",
"path": "/src/test.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> let encoding = w.spec();
Some(ParseResult {
path,
artists: vec![UNKNOWN_ENTRY.to_string()],
album: UNKNOWN_ENTRY.to_string(),
track: UNKNOWN_ENTRY.to_string(),
date: None,
track_pos: None,
channels: encoding.channels,
bit_depth: encod... | code_fim | hard | {
"lang": "rust",
"repo": "julientregoat/music-player",
"path": "/librarian/src/parse.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn parse_flac(p: PathBuf) -> Option<ParseResult> {
trace!("parsing flac {:?}", &p);
let mut builder = ParseResultBuilder::new(p);
let reader = match FlacReader::open_ext(
builder.path(),
FlacReaderOptions {
metadata_only: true,
read_vorbis_comment: t... | code_fim | hard | {
"lang": "rust",
"repo": "julientregoat/music-player",
"path": "/librarian/src/parse.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: julientregoat/music-player path: /librarian/src/parse.rs
use claxon::{FlacReader, FlacReaderOptions};
use hound::WavReader;
use log::{debug, error, trace, warn};
use rtag::{
frame::FrameBody,
metadata::{MetadataReader, Unit},
};
use std::{fs, path::PathBuf};
pub const UNKNOWN_ENTRY: &'s... | code_fim | hard | {
"lang": "rust",
"repo": "julientregoat/music-player",
"path": "/librarian/src/parse.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AMCorvi/allocator path: /src/registry/registry.rs
/*****************************************************
PROJECT : hpc_allocator_rust
VERSION : 0.1.0-dev
DATE : 05/2018
AUTHOR : Valat Sébastien
LICENSE : CeCILL-C
*********... | code_fim | hard | {
"lang": "rust",
"repo": "AMCorvi/allocator",
"path": "/src/registry/registry.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //check request before
let ret = registry.get_segment(ptr-1);
assert!(ret.is_none());
//check request after
let ret = registry.get_segment(ptr+size);
assert!(ret.is_none());
//first
for i in 0..size/2 {
let ret = registry.get_segment(ptr+i);
assert!(!ret.is_none());
assert_eq!(r... | code_fim | hard | {
"lang": "rust",
"repo": "AMCorvi/allocator",
"path": "/src/registry/registry.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> solve(input);
}
// Utilities
#[allow(dead_code)]
fn normal(x: usize, y: usize, width: usize) -> usize {
x + y * width
}
#[allow(dead_code)]
fn rev_normal(norm: usize, width: usize) -> (usize, usize) {
(norm % width, norm / width)
}
#[allow(dead_code)]
fn parse_num<T: std::str::FromStr>(str:... | code_fim | hard | {
"lang": "rust",
"repo": "icyJoseph/advent-of-code",
"path": "/2021/day-7/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match str.trim().parse::<T>() {
Ok(n) => n,
_ => panic!("Error parsing"),
}
}
#[allow(dead_code)]
fn to_int(bin: &str) -> u32 {
match u32::from_str_radix(bin, 2) {
Ok(n) => n,
_ => panic!("Error parsing binary to integer"),
}
}
#[allow(dead_code)]
fn string... | code_fim | hard | {
"lang": "rust",
"repo": "icyJoseph/advent-of-code",
"path": "/2021/day-7/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: icyJoseph/advent-of-code path: /2021/day-7/src/main.rs
use aoc;
fn solve(raw: String) -> () {
let positions = raw
.trim()
.split(",")
.map(|x| parse_num::<u32>(x))
.collect::<Vec<u32>>();
let max_position = *positions.iter().max().unwrap();
let simp... | code_fim | hard | {
"lang": "rust",
"repo": "icyJoseph/advent-of-code",
"path": "/2021/day-7/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>he width of all lines `>last_special_line`
#[globals_struct_field(TeXGlobals)]
pub(crate) static second_width: scaled = scaled::zero();
// @!first_indent:scaled; {left margin to go with |first_width|}
/// left margin to go with `first_width`
#[globals_struct_field(TeXGlobals)]
pub(crate) static first_inde... | code_fim | hard | {
"lang": "rust",
"repo": "harpsword/tex-rs",
"path": "/src/tex_the_program/section_0847.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: harpsword/tex-rs path: /src/tex_the_program/section_0847.rs
//! @ The length of lines depends on whether the user has specified
//! \.{\\parshape} or \.{\\hangindent}. If |par_shape_ptr| is not null, it
//! points to a $(2n+1)$-word record in |mem|, where the |info| in the first
//! word contain... | code_fim | hard | {
"lang": "rust",
"repo": "harpsword/tex-rs",
"path": "/src/tex_the_program/section_0847.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davechallis/ocypod path: /src/models/error.rs
//! Defines basic error and result types used throughout the application.
use std::{error::Error, fmt};
use actix_web::{http::StatusCode, HttpResponse, ResponseError};
use deadpool_redis::PoolError;
use redis::RedisError;
/// Result type used thro... | code_fim | hard | {
"lang": "rust",
"repo": "davechallis/ocypod",
"path": "/src/models/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<deadpool_redis::PoolError> for OcyError {
fn from(err: deadpool_redis::PoolError) -> Self {
OcyError::RedisConnection(err)
}
}
impl fmt::Display for OcyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
OcyError::Redis(err) => err... | code_fim | hard | {
"lang": "rust",
"repo": "davechallis/ocypod",
"path": "/src/models/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stepancheg/rust-http2 path: /httpbis/src/solicit/tests/common.rs
//! The module contains some common utilities for `solicit::http` tests.
use std::io::Write;
<|fim_suffix|>/// Creates a new `RawFrame` from two separate parts: the header and the payload.
/// Useful for tests that need to create... | code_fim | medium | {
"lang": "rust",
"repo": "stepancheg/rust-http2",
"path": "/httpbis/src/solicit/tests/common.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Creates a new `RawFrame` from two separate parts: the header and the payload.
/// Useful for tests that need to create frames, since they can easily specify the header and the
/// payload separately and use this function to stitch them together into a `RawFrame`.
#[cfg(test)]
pub fn raw_frame_from_par... | code_fim | medium | {
"lang": "rust",
"repo": "stepancheg/rust-http2",
"path": "/httpbis/src/solicit/tests/common.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if current_time > giveaway_data.pre_expiry as u64 {
return Ok(());
}
}
None => return Ok(()),
}
let guild = ctx.cache.guild(reaction.guild_id.unwrap()).await.unwrap();
let user_id = reaction.user_id.unwrap();
// Bias role ID
let... | code_fim | hard | {
"lang": "rust",
"repo": "bdashore3/ryzen-giveaway",
"path": "/src/reactions/giveaway.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bdashore3/ryzen-giveaway path: /src/reactions/giveaway.rs
use std::time::{SystemTime, UNIX_EPOCH};
use serenity::{framework::standard::CommandResult, model::prelude::*, prelude::*};
use uuid::Uuid;
use crate::structures::cmd_data::ConnectionPool;
pub async fn add_giveaway_entries(ctx: &Contex... | code_fim | hard | {
"lang": "rust",
"repo": "bdashore3/ryzen-giveaway",
"path": "/src/reactions/giveaway.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Bias role ID
let noble_id = RoleId::from(554090254664073237);
let member = guild.member(ctx, user_id).await?;
if member.roles.contains(&noble_id) {
sqlx::query!(
"INSERT INTO entries VALUES($1, $2, $3)",
Uuid::new_v4(),
user_id.0 as i64,
... | code_fim | hard | {
"lang": "rust",
"repo": "bdashore3/ryzen-giveaway",
"path": "/src/reactions/giveaway.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>or
patch
)
}
;
println
!
(
"
Version
:
{
}
"
version
)
;
if
matches
.
contains_id
(
"
config
"
)
{
let
input
=
matches
.
get_one
:
:
<
PathBuf
>
(
"
INPUT_FILE
"
)
.
or_else
(
|
|
matches
.
get_one
:
:
<
PathBuf
>
(
"
spec
-
in
"
)
)
.
unwrap_or_else
(
|
|
{
cmd
.
error
(
ErrorKind
:
:
MissingRequiredArgu... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/clap/examples/tutorial_builder/04_04_custom.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (i, v) in s.chars().enumerate() {
if v == 'A' && !alock {
aidx = i;
alock = true;
}
if v == 'Z' {
zidx = i
}
}
println!("{}", zidx - aidx + 1);
}<|fim_prefix|>// repo: k-jun/atcoder-abc path: /src/abc53_b.rs
use std::io::... | code_fim | medium | {
"lang": "rust",
"repo": "k-jun/atcoder-abc",
"path": "/src/abc53_b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: k-jun/atcoder-abc path: /src/abc53_b.rs
use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
let stdin = stdin();
let stdin = stdin.lock();
let token: String = stdin
.bytes()
.map(|c| c.expect("failed to read char") as char)
.skip_while(|c|... | code_fim | medium | {
"lang": "rust",
"repo": "k-jun/atcoder-abc",
"path": "/src/abc53_b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arlyon/rust-workshop path: /homework-1-2/src/main.rs
/*
Problem 2 - In for the long haul
--------------------------------
You now have an input file with the following content:
---8<---
This is your input file
Anything which is not one of the important characters will be ignored
... | code_fim | hard | {
"lang": "rust",
"repo": "arlyon/rust-workshop",
"path": "/homework-1-2/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() -> Result<(), Box<dyn error::Error>> {
let file_name = env::args().nth(1).ok_or("No file name provided!")?;
let content = fs::read_to_string(&file_name)?;
let filtered_content = content
.chars()
.filter(|c1| "<>+-.,[]".contains(|c2: char| c2.eq(c1)))
.collec... | code_fim | hard | {
"lang": "rust",
"repo": "arlyon/rust-workshop",
"path": "/homework-1-2/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: suhanyujie/linked-list-rs path: /src/third.rs
use std::rc::Rc;
type Link<T> = Option<Rc<Node<T>>>;
#[derive(PartialEq, Eq, Debug)]
struct Node<T> {
elem: T,
next: Link<T>,
}
#[derive(PartialEq, Eq, Debug)]
pub struct List<T> {
head: Link<T>,
}
impl<T> List<T> {
pub fn new() -... | code_fim | hard | {
"lang": "rust",
"repo": "suhanyujie/linked-list-rs",
"path": "/src/third.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let list: List<i32> = List::new();
assert_eq!(list.head(), None);
let list = list.append(3);
assert_eq!(list.head(), Some(&3));
}
}<|fim_prefix|>// repo: suhanyujie/linked-list-rs path: /src/third.rs
use std::rc::Rc;
type Link<T> = Option<Rc<Node<T>>>;
#[derive(Parti... | code_fim | hard | {
"lang": "rust",
"repo": "suhanyujie/linked-list-rs",
"path": "/src/third.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vincenthouyi/LakeOS path: /userland/console/src/console.rs
use core::task::Waker;
use core::{
pin::Pin,
task::{Context, Poll},
};
use alloc::collections::LinkedList;
use alloc::sync::Arc;
use futures_util::io::{AsyncRead, AsyncWrite};
use futures_util::stream::Stream;
use spin::Mutex;
... | code_fim | hard | {
"lang": "rust",
"repo": "vincenthouyi/LakeOS",
"path": "/userland/console/src/console.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AsyncRead for ConsoleExt {
fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<io::Result<usize>> {
let mut read_len = 0;
let mut inner = self.inner.lock();
while read_len < buf.len() {
if inner.can_re... | code_fim | hard | {
"lang": "rust",
"repo": "vincenthouyi/LakeOS",
"path": "/userland/console/src/console.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if write_len == 0 {
inner.tx_waker.push_back(cx.waker().clone());
inner.enable_tx_irq();
Poll::Pending
} else {
Poll::Ready(Ok(write_len))
}
}
fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<io::Result<()>>... | code_fim | hard | {
"lang": "rust",
"repo": "vincenthouyi/LakeOS",
"path": "/userland/console/src/console.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MaxOhn/Bathbot path: /bathbot/src/manager/twitch.rs
use bathbot_psql::Database;
use bathbot_util::CowUtils;
use eyre::{Result, WrapErr};
use rosu_v2::request::UserId;
use twilight_model::id::{marker::ChannelMarker, Id};
#[derive(Copy, Clone)]
pub struct TwitchManager<'d> {
psql: &'d Databas... | code_fim | hard | {
"lang": "rust",
"repo": "MaxOhn/Bathbot",
"path": "/bathbot/src/manager/twitch.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn untrack_all(self, channel: Id<ChannelMarker>) -> Result<()> {
self.psql
.delete_tracked_twitch_streams(channel)
.await
.wrap_err("failed to remove tracked twitch streams")
}
}<|fim_prefix|>// repo: MaxOhn/Bathbot path: /bathbot/src/manager/... | code_fim | hard | {
"lang": "rust",
"repo": "MaxOhn/Bathbot",
"path": "/bathbot/src/manager/twitch.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BurntSushi/ripgrep path: /crates/pcre2/src/error.rs
use std::error;
use std::fmt;
/// An error that can occur in this crate.
///
/// Generally, this error corresponds to problems building a regular
/// expression, whether it's in parsing, compilation or a problem with
/// guaranteeing a configu... | code_fim | hard | {
"lang": "rust",
"repo": "BurntSushi/ripgrep",
"path": "/crates/pcre2/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.kind {
ErrorKind::Regex(_) => "regex error",
ErrorKind::__Nonexhaustive => unreachable!(),
}
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.kind {
ErrorKind::Regex(ref s... | code_fim | hard | {
"lang": "rust",
"repo": "BurntSushi/ripgrep",
"path": "/crates/pcre2/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //Creates a new Ray transformed by a matrix
pub fn transform(ray: &Ray, matrix: &Matrix4x4) -> Ray {
Ray {
origin: matrix * &ray.origin,
direction: matrix * &ray.direction,
}
}
//Lists ray intersections within a scene
pub fn intersect_scene<... | code_fim | medium | {
"lang": "rust",
"repo": "wyattlake/rust-ray-tracer",
"path": "/src/ray_tracing/ray.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //Calculates the position of a ray
pub fn position(ray: &Ray, t: f32) -> Vec4 {
&ray.origin + (&ray.direction * t)
}
//Creates a new Ray transformed by a matrix
pub fn transform(ray: &Ray, matrix: &Matrix4x4) -> Ray {
Ray {
origin: matrix * &ray.origin,... | code_fim | hard | {
"lang": "rust",
"repo": "wyattlake/rust-ray-tracer",
"path": "/src/ray_tracing/ray.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wyattlake/rust-ray-tracer path: /src/ray_tracing/ray.rs
use crate::core::vector::*;
use crate::ray_tracing::intersection::*;
use crate::core::matrix::Matrix4x4;
use crate::world::scene::*;
//A Ray has a origin (point) and a direction (vector)
#[derive(Debug, PartialEq, Clone)]
pub struct Ray {
... | code_fim | hard | {
"lang": "rust",
"repo": "wyattlake/rust-ray-tracer",
"path": "/src/ray_tracing/ray.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mezeipetister/ifeq path: /src/lib.rs
/// If variable is equal with the given
/// parameter returns true, otherwise false.
pub trait Is<T> {
fn is(&self, is: T) -> bool;
}
/// If variable value is exactly the given
/// parameter, returns true, or false.
pub trait IfEq<T> {
fn if_eq(&self... | code_fim | hard | {
"lang": "rust",
"repo": "mezeipetister/ifeq",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if *self {
return msg.to_owned();
}
msg.to_owned()
}
}
impl<R, F> Then<R, F> for bool {
fn then(&self, f: F) -> R
where
F: Fn() -> R,
{
f()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
asser... | code_fim | hard | {
"lang": "rust",
"repo": "mezeipetister/ifeq",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn reset(&mut self) {
self.counter = self.period;
}
}<|fim_prefix|>// repo: goooosick/joy path: /src/apu/parts/timer.rs
pub struct Timer {
period: u32,
counter: u32,
}
<|fim_middle|>impl Timer {
pub fn new(period: u32) -> Self {
Timer {
period: period,... | code_fim | hard | {
"lang": "rust",
"repo": "goooosick/joy",
"path": "/src/apu/parts/timer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_period(&mut self, period: u32) {
self.period = period;
}
pub fn reset(&mut self) {
self.counter = self.period;
}
}<|fim_prefix|>// repo: goooosick/joy path: /src/apu/parts/timer.rs
pub struct Timer {
period: u32,
counter: u32,
}
<|fim_middle|>impl Time... | code_fim | hard | {
"lang": "rust",
"repo": "goooosick/joy",
"path": "/src/apu/parts/timer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: goooosick/joy path: /src/apu/parts/timer.rs
pub struct Timer {
period: u32,
counter: u32,
}
impl Timer {
pub fn new(period: u32) -> Self {
Timer {
period: period,
counter: 0,
}
}
<|fim_suffix|> pub fn set_period(&mut self, period: u32)... | code_fim | hard | {
"lang": "rust",
"repo": "goooosick/joy",
"path": "/src/apu/parts/timer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut s = String::new();
f.read_to_string(&mut s)?;
Ok(s)
}
//* These method can also be chained
fn __read_username_from_file() -> Result<String, Error> {
let mut s = String::new();
File::open("hello.txt")?.read_to_string(&mut s)?;
Ok(s)
}
//* You can even use the ?-oper... | code_fim | hard | {
"lang": "rust",
"repo": "olliurban/learn-rust",
"path": "/rust-lang-book/error-handling/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: olliurban/learn-rust path: /rust-lang-book/error-handling/src/main.rs
use std::fs::File;
use std::io::{self, Error, ErrorKind, Read};
fn main() {
//* panic! - unrecoverable error that causes the program to abort
{
//* Panic occurs when accessing a vector at an invalid index
... | code_fim | hard | {
"lang": "rust",
"repo": "olliurban/learn-rust",
"path": "/rust-lang-book/error-handling/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::ipv4::{IpV4Packet, IpV4Protocol};<|fim_prefix|>// repo: passchaos/tokio-ping path: /src/packet/mod.rs
mod icmpv4;
mod icmpv6;
mod ipv4;
<|fim_middle|>pub use self::icmpv4::IcmpV4Message;
pub use self::icmpv6::IcmpV6Message;
| code_fim | medium | {
"lang": "rust",
"repo": "passchaos/tokio-ping",
"path": "/src/packet/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: passchaos/tokio-ping path: /src/packet/mod.rs
mod icmpv4;
mod icmpv6;
mod ipv4;
<|fim_suffix|>pub use self::ipv4::{IpV4Packet, IpV4Protocol};<|fim_middle|>pub use self::icmpv4::IcmpV4Message;
pub use self::icmpv6::IcmpV6Message;
| code_fim | medium | {
"lang": "rust",
"repo": "passchaos/tokio-ping",
"path": "/src/packet/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut num = Number::Byte(10);
num = Number::Int(1);
num = Number::Long(2);
match num {
Number::Byte(b) => println!("byte: {}", b),
Number::Short(s) => println!("short: {}", s),
Number::Int(i) => println!("int: {}", i),
Number::Long(l) => println!("long: {... | code_fim | medium | {
"lang": "rust",
"repo": "Xianzhan/frame-rs",
"path": "/05-enumerate/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Xianzhan/frame-rs path: /05-enumerate/src/main.rs
enum Number {
Byte(i8),
Short(i16),
Int(i32),
Long(i64),
}
<|fim_suffix|> if let Number::Short(s) = Number::Short(11) {
println!("short: {}", s);
}
}<|fim_middle|>fn main() {
let mut num = Number::Byte(10);
... | code_fim | hard | {
"lang": "rust",
"repo": "Xianzhan/frame-rs",
"path": "/05-enumerate/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match num {
Number::Byte(b) => println!("byte: {}", b),
Number::Short(s) => println!("short: {}", s),
Number::Int(i) => println!("int: {}", i),
Number::Long(l) => println!("long: {}", l),
// _ => println!("impossible"),
}
if let Number::Short(s) = Numbe... | code_fim | medium | {
"lang": "rust",
"repo": "Xianzhan/frame-rs",
"path": "/05-enumerate/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Calls the subexec for the matched subcommand.
pub fn subexec(subcmd: (&str, Option<&ArgMatches>)) -> Failure {
match subcmd {
("apply", Some(m)) => apply::exec(m),
("list", Some(m)) => list::exec(m),
("read", Some(m)) => read::exec(m),
_ => Err("no matching command ... | code_fim | hard | {
"lang": "rust",
"repo": "dudanian/license",
"path": "/src/bin/license/cmds.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod apply;
mod list;
mod read;
/// Returns currently supported subcommands.
pub fn subcommands<'a, 'b>() -> Vec<App<'a, 'b>> {
vec![
apply::subcommand(),
list::subcommand(),
read::subcommand(),
]
}
/// Calls the subexec for the matched subcommand.
pub fn subexec(subcmd: (... | code_fim | medium | {
"lang": "rust",
"repo": "dudanian/license",
"path": "/src/bin/license/cmds.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dudanian/license path: /src/bin/license/cmds.rs
//! Subcommands for the application.
//!
//! Each subcommand is implemented in it's own submodule.
//! See the nested submodules for more information on
//! specific commands.
use crate::prelude::*;
<|fim_suffix|>/// Calls the subexec for the mat... | code_fim | hard | {
"lang": "rust",
"repo": "dudanian/license",
"path": "/src/bin/license/cmds.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut removals = Vec::new();
for entry in std::fs::read_dir(".")? {
let dir = entry?;
let path = dir.path();
if let Some(ext) = path.extension() {
let raw_ext = if ext == "JPG" {
"RW2"
} else if ext == "jpg" {
"dng"
... | code_fim | medium | {
"lang": "rust",
"repo": "hsivonen/rmjpg",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hsivonen/rmjpg path: /src/main.rs
// Copyright 2019 Henri Sivonen. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT... | code_fim | medium | {
"lang": "rust",
"repo": "hsivonen/rmjpg",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: trembel/ambiq-apollo3p-pac path: /src/ctimer/tmr4.rs
#[doc = "Reader of register TMR4"]
pub type R = crate::R<u32, super::TMR4>;
#[doc = "Writer for register TMR4"]
pub type W = crate::W<u32, super::TMR4>;
#[doc = "Register TMR4 `reset()`'s with value 0"]
impl crate::ResetValue for super::TMR4 {... | code_fim | hard | {
"lang": "rust",
"repo": "trembel/ambiq-apollo3p-pac",
"path": "/src/ctimer/tmr4.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Bits 0:15 - Counter/Timer A4."]
#[inline(always)]
pub fn cttmra4(&self) -> CTTMRA4_R {
CTTMRA4_R::new((self.bits & 0xffff) as u16)
}
}
impl W {
#[doc = "Bits 16:31 - Counter/Timer B4."]
#[inline(always)]
pub fn cttmrb4(&mut self) -> CTTMRB4_W {
CTTMRB4_W { w: self }... | code_fim | hard | {
"lang": "rust",
"repo": "trembel/ambiq-apollo3p-pac",
"path": "/src/ctimer/tmr4.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> p_context: *mut RTIMULibContext,
orientation: *mut CAllData,
) -> libc::c_int;
}
#[repr(C)]
#[derive(Default)]
struct CAllData {
timestamp: libc::uint64_t,
fusion_pose_valid: libc::c_int,
fusion_pose: CVector3D,
gyro_valid: libc::c_int,
gyro: CVector3D,
accel_v... | code_fim | hard | {
"lang": "rust",
"repo": "elprl/sensehat-rs",
"path": "/src/lsm9ds1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn set_accel_only(&mut self) {
unsafe {
rtimulib_set_sensors(self.rtimulib_ref, 0, 1, 0);
}
}
pub(crate) fn get_imu_data(&mut self) -> Result<ImuData, Error> {
let mut temp = CAllData::default();
let result = unsafe { rtimulib_wrapper_get... | code_fim | hard | {
"lang": "rust",
"repo": "elprl/sensehat-rs",
"path": "/src/lsm9ds1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elprl/sensehat-rs path: /src/lsm9ds1.rs
//! * Driver for the LSM9DS1 accelerometer
//! See `http://www.st.com/en/mems-and-sensors/lsm9ds1.html`
//!
//! Driver needs to follow `https://github.com/RPi-Distro/python-sense-hat/blob/master/sense_hat/sense_hat.py`
//! in how it manages the settings fi... | code_fim | hard | {
"lang": "rust",
"repo": "elprl/sensehat-rs",
"path": "/src/lsm9ds1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MDeiml/attomath path: /src/error.rs
use crate::types::*;
/// An error which is produced when trying to proof something incorrect
#[derive(Debug, PartialEq, Eq)]
pub enum ProofError {
/// Error produced when trying to unify expressions with different operators (see
/// [`Expression::unif... | code_fim | hard | {
"lang": "rust",
"repo": "MDeiml/attomath",
"path": "/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ession/struct.Expression.html#method.unify)). Contains the
/// identifier for the variable and the mismatched subexpressions.
VariableMismatch(Identifier, Box<[Identifier]>, Box<[Identifier]>),
/// Error produced when trying to unify statements with different judgements (see
/// [`Statemen... | code_fim | hard | {
"lang": "rust",
"repo": "MDeiml/attomath",
"path": "/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ent::unify`](../statement/struct.Statement.html#method.unify)). Contains the
/// mismatched judgements.
JudgementMismatch(Judgement, Judgement),
/// Error produced when trying to create a theorem with conflicting dvrs (see
/// [`DVR`](../dvr/struct.DVR.html)).
DVRError(Identifier),
}<|... | code_fim | hard | {
"lang": "rust",
"repo": "MDeiml/attomath",
"path": "/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>],
"../../emtests/test_unary_literal.out"
);
}<|fim_prefix|>// repo: forkkit/wasmer path: /lib/emscripten-tests/tests/emtests/test_unary_literal.rs
#[test]
#[ignore]
fn test_test_unary_literal() {
assert_emscripten_output!(
"../../emtests/test_unary_l<|fim_middle|>iteral.wasm",
... | code_fim | easy | {
"lang": "rust",
"repo": "forkkit/wasmer",
"path": "/lib/emscripten-tests/tests/emtests/test_unary_literal.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: forkkit/wasmer path: /lib/emscripten-tests/tests/emtests/test_unary_literal.rs
#[test]
#[ignore]
fn test_test_unary_literal() {
assert_emscripten_output!(
"../../emtests/test_unary_l<|fim_suffix|>],
"../../emtests/test_unary_literal.out"
);
}<|fim_middle|>iteral.wasm",
... | code_fim | easy | {
"lang": "rust",
"repo": "forkkit/wasmer",
"path": "/lib/emscripten-tests/tests/emtests/test_unary_literal.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(Permission::Allow.check("hi").unwrap(), Some("hi"));
assert_eq!(Permission::Deny.check("hi").unwrap(), None);
assert!(Permission::Forbid.check("hi").is_err());
}
#[test]
fn check_opt() {
assert_eq!(Permission::Allow.check_opt("hi"), Some("hi"));
... | code_fim | medium | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix-sec/tests/sec.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Byron/gitoxide path: /gix-sec/tests/sec.rs
pub type Result<T = ()> = std::result::Result<T, Box<dyn std::error::Error>>;
mod trust {
use gix_sec::Trust;
#[test]
fn ordering() {
assert!(Trust::Reduced < Trust::Full);
}
}
mod permission {
use gix_sec::Permission;
<|... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix-sec/tests/sec.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn is_allowed() {
assert!(Permission::Allow.is_allowed());
assert!(!Permission::Deny.is_allowed());
assert!(!Permission::Forbid.is_allowed());
}
}
mod identity;<|fim_prefix|>// repo: Byron/gitoxide path: /gix-sec/tests/sec.rs
pub type Result<T = ()> = std::res... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix-sec/tests/sec.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paritytech/substrate path: /frame/grandpa/src/tests.rs
ome(0)),
Error::<Test>::ChangePending
);
Grandpa::on_finalize(i);
header = System::finalize();
}
// change has been applied at the end of block 6.
// add a normal change.
{
initialize_block(7, header.hash());
ass... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/substrate",
"path": "/frame/grandpa/src/tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.