blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
dcf1d73d009f733553c6c56c068e8fa94d23c7c0 | Rust | novelistapp/novelist | /novelist-core/src/state/text.rs | UTF-8 | 2,401 | 4.0625 | 4 | [
"MIT"
] | permissive | /// Common text types shared between the data and I/O layers
use rayon::prelude::*;
/// A complete text Paragraph that ends with a "." (normally)
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Paragraph {
snippets: Vec<Sentence>,
}
impl Paragraph {
pub fn new() -> Paragraph {
Paragraph {
... | true |
e556b1530df9fdfd8a8077a01e116c5a1235d695 | Rust | seanchen1991/rune | /crates/rune/src/ast/fn_arg.rs | UTF-8 | 1,159 | 3.25 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::ast;
use crate::{Parse, ParseError, ParseErrorKind, Parser, Spanned, ToTokens};
/// A single argument in a closure.
///
/// # Examples
///
/// ```rust
/// use rune::{parse_all, ast};
///
/// parse_all::<ast::FnArg>("self").unwrap();
/// parse_all::<ast::FnArg>("_").unwrap();
/// parse_all::<ast::FnArg>("abc... | true |
d922fabef36d0f78c33920d6cb3a27a6001d99cd | Rust | bryanburgers/advent-of-code-2020 | /day-10/src/main.rs | UTF-8 | 2,608 | 3.46875 | 3 | [] | no_license | use std::io::Read;
fn main() {
let mut input = String::new();
std::io::stdin().read_to_string(&mut input).unwrap();
let mut joltages = input
.trim()
.split('\n')
.map(|line| line.parse::<usize>())
.collect::<Result<Vec<_>, _>>()
.unwrap();
joltages.sort();
... | true |
0fa268e10e7f9df5ce81b3ab4453a69ced4e4e42 | Rust | tomo3110/ejdict-rs | /crates/cli/src/main.rs | UTF-8 | 5,051 | 2.921875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-3-Clause"
] | permissive | use clap::{
app_from_crate, crate_authors, crate_description, crate_name, crate_version, App, Arg,
SubCommand,
};
use ejdict_rs::{Result, SearchMode, Word};
use prettytable::{Cell, Row, Table};
use std::process;
use std::str::FromStr;
fn main() {
let app = setup_app();
let matches = app.get_matches();
... | true |
2c7fdabc5745c816158bd225957eeb1ceedb4f02 | Rust | kristofvdj88/battleships_iscp | /smartcontract/src/battleship_iscp.rs | UTF-8 | 13,294 | 2.78125 | 3 | [] | no_license | use battleship::*;
use iota_sc_utils::*;
use wasmlib::*;
use crate::consts::*;
use crate::helpers::*;
use crate::structures::*;
pub fn create_game(ctx: &ScFuncContext) {
ctx.log("create_game");
// Reads argument called "createGameRequestKey" and tries to deserialize it to the CreateGameRequest structure
... | true |
32b7e10b4c5492e87d47a072ad73b3c1cb33c28c | Rust | hencrice/leetcode-rust | /src/q00058_length_of_last_word.rs | UTF-8 | 696 | 3.640625 | 4 | [
"Apache-2.0"
] | permissive | pub struct Solution {}
impl Solution {
pub fn length_of_last_word(s: String) -> i32 {
let iter = s.split_ascii_whitespace();
match iter.last() {
Some(word) => word.len() as i32,
_ => 0,
}
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_las... | true |
a89761dd4a7309134803acdc60a00d06893ac224 | Rust | nilsmartel/substr | /src/main.rs | UTF-8 | 1,137 | 3.15625 | 3 | [] | no_license | use std::env::args;
use std::io::Read;
fn main() {
let mut arg_start = 1;
let mut input = String::new();
std::io::stdin().read_to_string(&mut input);
let arguments: Vec<String> = args().collect();
}
struct Cut {
lines: bool,
start: Option<usize>,
end: Option<usize>,
}
impl Cut {
fn ... | true |
c26aa4f68c3938fb18e3c40ff29ab59062bc7b05 | Rust | Dominator008/rust_os | /Usermode/libwtk/image.rs | UTF-8 | 2,287 | 2.75 | 3 | [
"BSD-2-Clause"
] | permissive | //
//
//
use geom::{Rect,Px};
use surface::Colour;
/// Static image wrapper
pub struct Image<T: Buffer>
{
has_changed: ::std::cell::Cell<bool>,
data: T,
}
impl<T: Buffer> Image<T>
{
pub fn new(i: T) -> Image<T> {
Image {
has_changed: ::std::cell::Cell::new(true),
data: i,
}
}
pub fn force_redraw(&self... | true |
3147bd2a3bc976b481803ac7ebcfa606c40822cd | Rust | phial3/mysql_cdc | /src/responses/handshake_packet.rs | UTF-8 | 2,574 | 2.8125 | 3 | [
"MIT"
] | permissive | use crate::constants::capability_flags;
use crate::errors::Error;
use crate::extensions::{read_null_term_string, read_string};
use byteorder::{LittleEndian, ReadBytesExt};
use std::io::{Cursor, Read};
/// Initial handshake packet sent by the server.
/// <a href="https://mariadb.com/kb/en/library/connection/#initial-ha... | true |
17f3a4614b88d396c378408209fcdf5f39b54e53 | Rust | zhao1jin4/vscode_rust_workspace | /rustc_basic/src/25_trait_adv_add.rs | UTF-8 | 1,378 | 3.828125 | 4 | [] | no_license |
fn main(){
assert_eq!(Point { x: 1, y: 0 } + Point { x: 2, y: 3 },
Point { x: 3, y: 3 }); //运算符重载 +
let res = Millimeters(3) + Meters(1);
println!("{}",res.0);
}
//Iterator源码
pub trait Iterator1 {
type Item; //type ,这个 trait 的实现者会指定 Item 的具体类型,然而不管实现者指定何种类型, next 方法都会返回一个包含了此具... | true |
f516f96fb8f7157deaab42772b02dda4e3418698 | Rust | yspace/begin_rust | /src/the_book/common_prog_concept/mod.rs | UTF-8 | 736 | 3.078125 | 3 | [
"MIT"
] | permissive |
pub const IS_DEBUG : bool= true ;
// 导出模块
pub mod data_types ;
pub mod functions ;
pub mod control_flow ;
pub fn action_variables(){
let mut x = 5 ;
println!("The value of x is {} ", x) ;
x = 6;
println!("The value of x is {} ", x) ;
// ## 常量
const MAX_POINTS : u32 = 100_100 ;
println... | true |
1d4efaaee0e7d9647742fa64a6baa6a25e7b0bdf | Rust | derekdreery/enumerate-split | /src/lib.rs | UTF-8 | 2,938 | 3.765625 | 4 | [] | no_license |
/// Don't use this struct directly, use enumerate_split
pub struct EnumerateSplit<Iter, T>
where Iter: Iterator<Item = T>, T: PartialEq {
iter: Iter,
split_value: T,
block_number: usize,
block_position: usize
}
impl<Iter, T> EnumerateSplit<Iter, T>
where Iter: Iterator<Item = T>, T: PartialEq {
#... | true |
ec26938bfc103cfed2ae0572a5c4abb1fb982274 | Rust | gen0083/atcoder_python | /rust/abc214/src/bin/c.rs | UTF-8 | 971 | 2.90625 | 3 | [] | no_license | use std::cmp::min;
use proconio::input;
fn main() {
input!{
n: usize,
s: [u64; n],
mut t: [u64; n],
}
let mut min_t = 1_000_000_001u64;
let mut min_s = 1_000_000_001u64;
let mut min_index = 0;
for i in 0..n {
match min_t.cmp(&t[i]) {
std::cmp::Orderi... | true |
4b4d4a8b4ed11e725578a72efafa8d4d9fc5b2b4 | Rust | adrien-ben/imgui-rs-vulkan-renderer | /examples/collapsing_header.rs | UTF-8 | 2,313 | 2.953125 | 3 | [
"MIT"
] | permissive | mod common;
use common::*;
use imgui::*;
use simple_logger::SimpleLogger;
use std::error::Error;
const APP_NAME: &str = "collapsing headers";
fn main() -> Result<(), Box<dyn Error>> {
SimpleLogger::new().init()?;
let mut state = State {
render_closable: true,
};
System::new(APP_NAME)?.run((),... | true |
e3af9a27f79287920350809054ddf598ec63ddd0 | Rust | wirefunc/wirefunc | /src/record.rs | UTF-8 | 1,286 | 3.234375 | 3 | [
"BSD-3-Clause"
] | permissive | extern crate byteorder;
// TODO should make this pub struct
pub type FieldId = u32;
/// Read the field presence table from a record's data bytes.
///
/// * The presence table is always at the beginning of a record's data bytes.
/// * Each page of the presence table is 64 bits long.
/// * The 64th bit in a page is 1 i... | true |
3355a70eb0cdb356ce795ab5ca7cb5505c325f82 | Rust | akks800/atcoder | /arc104/src/bin/c.rs | UTF-8 | 3,151 | 2.78125 | 3 | [] | no_license | use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;
#[derive(Clone, Debug, Default)]
struct Struct;
//#[proconio::fastout]
fn main() {
inpu... | true |
038d84b18c6e18cfa2b7568b416c3898a7ca3fc8 | Rust | merll/mutebtn | /src/pulse.rs | UTF-8 | 5,041 | 3 | 3 | [
"MIT"
] | permissive | use pulsectl::controllers::{DeviceControl, SourceController};
use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub enum AudioMessage {
GetMuteStatus,
SetMuteStatus(bool),
Terminate,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum PulseMuteDevice {
All,
De... | true |
96f8b2efc7d0c0a2cc8b7dc4ab34d37f94468e07 | Rust | flier/quick-csv | /src/index.rs | UTF-8 | 15,402 | 3.046875 | 3 | [] | no_license | //! The module provides data structures for indexing CSV data.
use core::ops::{Deref, DerefMut, Range, RangeFrom};
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
cfg_if! {
if #[cfg(target_feature = "avx")] {
use crate::avx::*;
} else ... | true |
91c337f06c336155fd0f7f670d5835ba5d5a8745 | Rust | GavinRay97/reaper-rs | /main/high/src/fx.rs | UTF-8 | 26,470 | 2.609375 | 3 | [
"MIT"
] | permissive | use std::cell::Cell;
use std::ops::Deref;
use std::path::PathBuf;
use crate::fx_chain::FxChain;
use crate::fx_parameter::FxParameter;
use crate::guid::Guid;
use crate::option_util::OptionExt;
use crate::{ChunkRegion, FxChainContext, Project, Reaper, Track};
use reaper_medium::{
FxPresetRef, FxShowInstruction, Hwn... | true |
735fa01727e3e4c24311196992663662189a4a22 | Rust | astral-sh/ruff | /crates/ruff/src/rules/flake8_pyi/rules/duplicate_union_member.rs | UTF-8 | 2,740 | 2.5625 | 3 | [
"BSD-3-Clause",
"0BSD",
"LicenseRef-scancode-free-unknown",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0"
] | permissive | use ruff_python_ast::{self as ast, Expr, Ranged};
use rustc_hash::FxHashSet;
use std::collections::HashSet;
use crate::checkers::ast::Checker;
use crate::registry::AsRule;
use crate::rules::flake8_pyi::helpers::traverse_union;
use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation};
use ruff_macros::{der... | true |
a917ce33d5b6af5a36826da0934e99769e016c6e | Rust | brayniac/rpc-perf | /src/clients/http2.rs | UTF-8 | 8,846 | 2.671875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use super::*;
use crate::net::Connector;
use bytes::Bytes;
use http_body_util::Empty;
use hyper::client::conn::http2::SendRequest;
use hyper::header::{HeaderName, HeaderValue};
use hyper::rt::Executor;
use hyper::{Request, Uri};
use std::future::Future;
#[derive(Clone)]
struct Queue<T> {
tx: async_channel::Sender<... | true |
e15907e1a5adef8298cf9917699f42cd72b8670c | Rust | rgrativol/lotto6 | /src/models.rs | UTF-8 | 1,822 | 3.28125 | 3 | [] | no_license | use std::path::Path;
use std::error::Error;
use std::fs::File;
use std::io::{BufReader, BufRead};
#[derive(Debug)]
pub struct Draw {
draw: String,
date: String,
n1: u8,
n2: u8,
n3: u8,
n4: u8,
n5: u8,
n6: u8,
n_bonus: u8,
}
impl Default for Draw{
fn default() -> Self {
... | true |
34e751aef1dc74f30cc20c0539bdb031860a41f4 | Rust | eras/ClickMuteJack | /src/config.rs | UTF-8 | 2,499 | 3.03125 | 3 | [
"MIT"
] | permissive | use serde_derive::{Deserialize, Serialize};
use std::fmt;
use std::fs;
use std::io;
use std::io::Write;
use thiserror::Error;
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)]
pub struct Delays {
pub mute_offset: f64,
pub mute_duration: f64,
pub fade: f64,
}
#[derive(Serialize, Deserialize,... | true |
b6c2b16fb6de221b8cf9ff3c36caa609cfdbbf09 | Rust | angelocatalani/hexagonal_architecture | /layered_pokedex/src/routes/pokemon_translated.rs | UTF-8 | 2,874 | 2.734375 | 3 | [] | no_license | use actix_web::{web, HttpResponse};
use anyhow::Context;
use crate::cache::CacheService;
use crate::pokeapi::{PokeapiService, Pokemon};
use crate::routes::errors::PokedexError;
use crate::translated::TranslatedService;
#[tracing::instrument(
name = "Getting pokemon with translated description",
skip(name, pokeapi_ser... | true |
75efecc8dbe2d660fb3442c1dbd26bd7f032c5df | Rust | kovrik/monocle | /src/attribute_info.rs | UTF-8 | 2,331 | 3.28125 | 3 | [] | no_license | use constant::*;
use constant_value::*;
use std::fmt;
use std::collections::HashMap;
pub struct AttributeInfo {
pub attribute_name_index: u16,
pub attribute_length: u32,
// TODO pub info[attribute_length];
}
impl fmt::Display for AttributeInfo {
fn fmt(&self, c: &mut fmt::Formatter) -> fmt::Result {
... | true |
12e9036813bfe0f11cebe1c474236d61fc34c55b | Rust | IThawk/rust-project | /rust-master/src/librustc_index/bit_set/tests.rs | UTF-8 | 10,668 | 3.078125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | use super::*;
extern crate test;
use test::Bencher;
#[test]
fn test_new_filled() {
for i in 0..128 {
let idx_buf = BitSet::new_filled(i);
let elems: Vec<usize> = idx_buf.iter().collect();
let expected: Vec<usize> = (0..i).collect();
assert_eq!(elems, expected);
}
}
#[test]
fn ... | true |
ed48c0b2989c23ab9a4574c14609e56b7b836e43 | Rust | metarmask/building-blocks | /crates/building_blocks_storage/src/octree_chunk_index.rs | UTF-8 | 6,413 | 2.59375 | 3 | [
"MIT"
] | permissive | use crate::{
active_clipmap_lod_chunks, Array3x1, ChunkMap3, ChunkedOctreeSet, ClipMapConfig3,
ClipMapUpdate3, GetMut, IterChunkKeys, LodChunkKey3, LodChunkUpdate3, OctreeSet,
SmallKeyHashMap,
};
use building_blocks_core::prelude::*;
use serde::{Deserialize, Serialize};
/// A `ChunkedOctreeSet` that inde... | true |
9f648346330520b59c5e3479d8a8e721344dfa24 | Rust | niklasad1/advent-of-code-2019 | /src/day4.rs | UTF-8 | 2,797 | 3.65625 | 4 | [
"MIT"
] | permissive | //! Day 4
use super::{AdventOfCodeBuilder, AdventOfCodeRunner, Error};
use std::ops::RangeInclusive;
/// Input
pub struct Input {
range: RangeInclusive<u32>,
}
impl AdventOfCodeBuilder<RangeInclusive<u32>> for Input {
type Error = Error;
type Output = Self;
fn build(range: RangeInclusive<u32>) -> Re... | true |
8d6548d4e0cef54e2041a25929b2dade9d366ada | Rust | alsacoin/alsacoin | /network/src/network.rs | UTF-8 | 1,149 | 3.0625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! # Network
//!
//! `network` is the module containing the network type and functions.
use crate::backend::TcpNetwork;
use crate::error::Error;
use crate::result::Result;
use config::network::NetworkConfig;
/// `NetworkFactory` is the factory for network types.
pub struct NetworkFactory {}
impl NetworkFactory {
... | true |
d7644b217999858cd51a44fb38240e1a15003d51 | Rust | samirsatam/scenario1 | /http/src/httprequest.rs | UTF-8 | 842 | 3.140625 | 3 | [] | no_license | #[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_method_into() {
let m: Method = "GET".into();
assert_eq!(m, Method::Get);
}
}
#[test]
fn test_version_into() {
let m: Version = "HTTP/1.1".into();
assert_eq!(m, Version::V1_1);
}
#[derive(Debug, PartialEq)]
pub enum Method ... | true |
cb9d0d891e540feeaeddb6898c7189959cdaf4ab | Rust | cshung/Competition | /rust_competition/src/leetcode/naming_a_company.rs | UTF-8 | 1,626 | 3.3125 | 3 | [] | no_license | use std::collections::HashMap;
use std::collections::HashSet;
impl Solution {
pub fn distinct_names(ideas: Vec<String>) -> i64 {
let mut by_tail: HashMap<String, HashSet<usize>> = HashMap::new();
let mut num_tails_by_head = vec![0; 26];
let mut intersection_count = vec![vec![0; 26]; 26];
... | true |
158f7f42f7d3f9f2a5a2722af45dbb1056878882 | Rust | EricQAQ/exercism-rust | /hamming/src/lib.rs | UTF-8 | 628 | 3.4375 | 3 | [] | no_license | use std::convert::Into;
pub fn hamming_distance<T: Into<String>>(s1: T, s2: T) -> Result<u32, ()> {
let (s1, s2) = (s1.into(), s2.into());
if s1.len() != s2.len() { return Err(()) }
Ok(s1.char_indices().fold(0, |acc, (index, c)| {
match c == s2.chars().nth(index).unwrap() {
true => acc,... | true |
d4b06f1095e0af75248f9dcc25f2796f6c0a7e27 | Rust | kevinmehall/rust-peg | /tests/run-pass/rule_args.rs | UTF-8 | 2,075 | 3.171875 | 3 | [
"MIT"
] | permissive | extern crate peg;
peg::parser!( grammar ra() for str {
use peg::ParseLiteral;
rule number() -> i64
= n:$(['0'..='9']+) { n.parse().unwrap() }
rule commasep<T>(x: rule<T>) -> Vec<T> = v:(x() ** ",") ","? {v}
rule bracketed<T>(x: rule<T>) -> T = "[" v:x() "]" {v}
pub rule list() -> Vec<i64... | true |
687b9639b7a648831359a62e1b9b7e1923fffed0 | Rust | IThawk/rust-project | /rust-master/src/librustc/middle/expr_use_visitor.rs | UTF-8 | 23,572 | 2.953125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | //! A different sort of visitor for walking fn bodies. Unlike the
//! normal visitor, which just walks the entire body in one shot, the
//! `ExprUseVisitor` determines how expressions are being used.
pub use self::ConsumeMode::*;
use self::OverloadedCallType::*;
use crate::hir::def::Res;
use crate::hir::def_id::DefId... | true |
d22644e6afb182f528eddcf2a730704f5490e05e | Rust | aguss787/doraemon | /src/core/resizer/processor.rs | UTF-8 | 1,577 | 2.671875 | 3 | [] | no_license | use std::vec::Vec;
use actix_multipart::Multipart;
use actix_web::http::StatusCode;
use actix_web::{http, web, Error as AcError, HttpResponse};
use futures::StreamExt;
use image;
use image::ImageError;
use rand;
use rand::Rng;
pub async fn process(mut payload: Multipart) -> Result<HttpResponse, AcError> {
match p... | true |
a7fc4b4731b740aa06413ae49363073f71c135bb | Rust | JAD3N/blocky-rs | /blocky-nbt/src/tag/mod.rs | UTF-8 | 5,832 | 2.90625 | 3 | [
"MIT"
] | permissive | mod kind;
mod index;
mod parser;
pub use kind::*;
pub use index::*;
pub use parser::*;
#[cfg(feature = "preserve-order")]
pub use indexmap::IndexMap as Map;
#[cfg(not(feature = "preserve-order"))]
pub use std::collections::HashMap as Map;
use regex::Regex;
use std::fmt;
lazy_static! {
static ref SIMPLE_PATTERN:... | true |
b32f5d5070e6eaeb57d909339ee9d3ada2ab4871 | Rust | olegvg/move-language-server | /src/config.rs | UTF-8 | 1,973 | 2.71875 | 3 | [
"MIT"
] | permissive | use std::path::PathBuf;
use libra_types::account_address::AccountAddress;
use move_lang::shared::Address;
use serde::Deserialize;
#[derive(Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum MoveDialect {
Libra,
DFinance,
}
#[derive(Debug)]
pub struct Config {
pub diale... | true |
b6f2e56d8e02973b77b1227c22835648d1f417e9 | Rust | namibj/jlight | /jlight-vm/src/runtime/fusion/optimizer.rs | UTF-8 | 3,597 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | use crate::bytecode::block::*;
use crate::bytecode::instructions::*;
use crate::runtime::object::Function;
use std::collections::{BTreeSet, HashMap, HashSet};
pub fn simplify_cfg(code: &mut Vec<BasicBlock>) {
if code.len() == 0 {
return;
}
let n_basic_blocks = code.len();
let mut out_edges: Vec<... | true |
f5fa1872d878923a0f8476247cd9ca46afa24115 | Rust | songlinshu/winsafe | /src/msg/pbm.rs | UTF-8 | 5,790 | 2.65625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! Progress bar control
//! [messages](https://docs.microsoft.com/en-us/windows/win32/controls/bumper-progress-bar-control-reference-messages),
//! whose constants have [`PBM`](crate::co::PBM) prefix.
use crate::aliases::WinResult;
use crate::co;
use crate::funcs::{HIWORD, LOWORD, MAKEDWORD};
use crate::msg::{... | true |
bd3cff3609ba9fa310ad683c8a3da4fcc1729015 | Rust | tspooner/rsrl | /rsrl/src/control/td/pal.rs | UTF-8 | 1,796 | 2.765625 | 3 | [
"MIT"
] | permissive | use crate::{
domains::Transition,
fa::StateActionUpdate,
utils::argmax_first,
Enumerable,
Function,
Handler,
Parameterised,
};
use std::ops::Index;
/// Persistent Advantage Learning
///
/// # References
/// - Bellemare, Marc G., et al. "Increasing the Action Gap: New Operators for
/// Reinf... | true |
15b4f2ebfc29884aeea2234f5b9c0c62e7559041 | Rust | jordanph/kubesci | /src/github/client/auth.rs | UTF-8 | 1,815 | 2.71875 | 3 | [] | no_license | use crate::github::auth::authenticate_app;
use chrono::Utc;
use log::info;
use reqwest::header::{ACCEPT, USER_AGENT};
use serde_derive::Deserialize;
pub struct GithubAuthorisationClient {
github_jwt_token: String,
base_url: String,
}
#[derive(Deserialize)]
struct InstallationAccessTokenResponse {
token: S... | true |
338cddb2d54854c8dcbf77f04d4c11856522dcf5 | Rust | memorysafety/sudo-rs | /test-framework/sudo-compliance-tests/src/sudo/flag_group.rs | UTF-8 | 5,377 | 2.5625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::collections::HashSet;
use pretty_assertions::assert_eq;
use sudo_test::{Command, Env, Group, User};
use crate::{Result, GROUPNAME, SUDOERS_ALL_ALL_NOPASSWD, USERNAME};
macro_rules! assert_snapshot {
($($tt:tt)*) => {
insta::with_settings!({
prepend_module_to_snapshot => false,
... | true |
378146023043b0ec42e41d56465e9dc4e4bbbea7 | Rust | jolestar/libra | /consensus/consensus-types/src/vote.rs | UTF-8 | 4,805 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{common::Author, timeout::Timeout, vote_data::VoteData};
use anyhow::{ensure, Context};
use libra_crypto::{ed25519::Ed25519Signature, hash::CryptoHash};
use libra_types::{
ledger_info::LedgerInfo, validator_signer::Valid... | true |
e55b8ac0a07d3196e99f61d8685b40848004030e | Rust | OwenMyers/z3stringnet | /src/datamodel/lattice.rs | UTF-8 | 18,375 | 3.078125 | 3 | [] | no_license | use super::Direction;
use super::Link;
use super::Point;
use super::BoundPoint;
use super::Vertex;
use super::cluster::increment_location;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_get_blank_vertex_from_real_point() {
let mut lat: Lattice = build_blank_lat(Point{x: 4, y: 4});
... | true |
3eed052c511a817b52bf5254485330b54e207169 | Rust | abhijeetbhagat/boa | /boa/src/exec/object/mod.rs | UTF-8 | 1,506 | 3.0625 | 3 | [
"Unlicense",
"MIT"
] | permissive | //! Object execution.
use super::{Executable, Interpreter};
use crate::{
builtins::value::{ResultValue, Value},
syntax::ast::node::MethodDefinitionKind,
syntax::ast::node::{Object, PropertyDefinition},
};
use std::borrow::Borrow;
impl Executable for Object {
fn run(&self, interpreter: &mut Interprete... | true |
a53050ddf2b0d323270a2ec95fcd990ace50b251 | Rust | joshuagollaher16/rhs | /src/Parser.rs | UTF-8 | 2,255 | 3.40625 | 3 | [] | no_license | use crate::Token::{Token, Operator};
use std::ops::Index;
pub struct Parser {
pub toks: Vec<Token>
}
impl Parser {
pub(crate) fn new(toks: Vec<Token>) -> Parser {
Parser {
toks
}
}
pub fn parse(&mut self) -> i32 {
let num_value = |index: usize| {
self.... | true |
3bc1d0fd707e05cc8848065dfed63ca9b5138857 | Rust | halfzebra/learning-rust | /course-notes/video-029/src/main.rs | UTF-8 | 585 | 3.796875 | 4 | [] | no_license | fn main() {
let plus_one = |x:i32| -> i32 { x + 1 };
let a = 6;
println!("{} + 1 = {}", a, plus_one(a));
let mut b = 2;
{
let plus_two = |x|
{
let mut z = x;
z += b;
z
};
println!("{} + 2 = {}", 3, plus_two(3));
}
// T ... | true |
4618cbe1ff17834d1a89c2ae7a81fa154b61b80c | Rust | bsaintjo/ray-tracing | /src/sphere.rs | UTF-8 | 1,318 | 3.0625 | 3 | [] | no_license | use crate::Vec3;
use crate::Ray;
use crate::hit;
pub struct Sphere {
center: Vec3,
radius: f32,
}
impl Sphere {
pub fn new(center: Vec3, radius: f32) -> Self {
Sphere { center, radius }
}
}
impl hit::Hittable for Sphere {
fn hit(&self, ray: &Ray, t_min: f32, t_max: f32, rec: &mut hit::Hit... | true |
b321290f90e4905c30416d3d1b6175317cf67858 | Rust | chrlen/Tokio-Docker | /src/main.rs | UTF-8 | 947 | 2.8125 | 3 | [] | no_license | #![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
use rocket::config::{Config, Environment};
extern crate serde;
use serde::{Deserialize, Serialize};
use std::{thread, time};
#[derive(Serialize, Deserialize, Debug)]
struct Point {
x: f64,
y: f64,
}
#[get("/")]
fn index() -> Strin... | true |
f21ddc397faa7ffa0d1adcf06867507eaba63a03 | Rust | mmitteregger/wiremock-client-rs | /examples/stateful_behaviour.rs | UTF-8 | 1,623 | 2.5625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::error::Error;
use wiremock_client::*;
use wiremock_client::stubbing::Scenario;
// Examples from: http://wiremock.org/docs/stateful-behaviour/
pub fn main() -> Result<(), Box<dyn Error>> {
let wire_mock = WireMockBuilder::new()
.port(8181) // If running on another port - the default is: 8080
... | true |
0a93575f5796ad96eb3674e088d783d40df199df | Rust | 5m1le71ger/pushbox | /src/solve.rs | UTF-8 | 1,865 | 3.046875 | 3 | [] | no_license | use pushboxmap::Point;
use pushboxmap::MoveOP;
use pushboxmap::PushBoxMap;
use std::collections::BTreeSet;
pub struct TraceNode (pub PushBoxMap,pub Option<MoveOP>);
//解题(当前地图状态,状态表,跟踪表)
pub fn solve_pushbox(pbm: &PushBoxMap, maps: &mut BTreeSet<PushBoxMap>, trace: &mut Vec<TraceNode>) -> bool {
//如果已经存在这个状态,则返回fa... | true |
1129d061fd7c757752bd368b228a3439dbf670c8 | Rust | najamelan/unicode-wrap | /src/lib.rs | UTF-8 | 3,891 | 3.03125 | 3 | [
"Unlicense"
] | permissive |
// # unicode-textwrap RFC
//
// So far this proposes an algorithm that is capable of wrapping one line. Neither is it expected to deal with existing newline characters or
// to find the ideal split point for justifying paragraphs.
//
// - use generators to generate split points.
// - use filters to forbid cer... | true |
fc86a256d0f3b6fa5c21514eef448196fa085261 | Rust | jmetz93/rust-practice | /src/vectors.rs | UTF-8 | 916 | 3.96875 | 4 | [
"MIT"
] | permissive | // vectors - resizable arrays
use std::mem;
pub fn run() {
let mut numbers: Vec<i32> = vec![1, 2, 3, 4];
// with arrays can reassign values of elements but cant add to it
// re-assign value
numbers[2] = 20;
// add onto vector
numbers.push(5);
numbers.push(6);
// pop off last val
numbers.pop();
p... | true |
b6629645e1c945e3126e7d137cc1103d906c5028 | Rust | Mr-Kumar-Abhishek/ion | /src/flow_control.rs | UTF-8 | 5,010 | 3.296875 | 3 | [
"MIT"
] | permissive | use super::to_num::ToNum;
use super::peg::Pipeline;
use super::status::{SUCCESS, FAILURE};
pub fn is_flow_control_command(command: &str) -> bool {
command == "end" || command == "if" || command == "else"
}
#[derive(Clone)]
pub enum Statement {
For(String, Vec<String>),
Function(String, Vec<String>),
I... | true |
f2daf3bec019b55ce759b8bd5a7e4a8b4e39d58c | Rust | tuguzT/bulls-and-cows | /src/lib.rs | UTF-8 | 4,119 | 3.90625 | 4 | [] | no_license | //! This is a library of the **"Bulls and Cows"** game
mod utils;
use std::error::Error;
use std::io::Write;
/// Structure of game configuration
pub struct Config {
/// Command line arguments passed to the game
commands: Vec<String>,
}
impl Config {
/// Constructor of the Config object
pub fn new() ... | true |
3b335c2fdf7d17395d61755482623f68144f3a52 | Rust | cosarara/rustbox | /examples/hello-world.rs | UTF-8 | 1,181 | 2.609375 | 3 | [
"MIT"
] | permissive | #![feature(io)]
#![feature(core)]
#![feature(old_io)]
extern crate rustbox;
use std::char;
use std::old_io::stdio;
use std::error::Error;
use std::default::Default;
use rustbox::{Color, RustBox, InitOptions};
use rustbox::Key;
fn main() {
let rustbox = match RustBox::init(InitOptions {
buffer_stderr: st... | true |
0731d2abc7554ae37487a088ae43634627058065 | Rust | andrewkerr9000/rust-dojo | /concurrency/5_shared_memory/2_shared_mutable.rs | UTF-8 | 827 | 3.3125 | 3 | [] | no_license | // To share mutable memory we must wrap the variable in a mutex (or rwlock)
// which we then wrap in an Arc
// This prevents data races
// It does not prevent deadlock or other race condition
// http://doc.rust-lang.org/std/sync/struct.Mutex.html
// using try instead of spawn just to ensure
#![crate_name = "shared... | true |
70075f1d7c756a31fd0c68e5898fd111dc1e97b1 | Rust | LukasKalbertodt/drencher | /drencher/src/board.rs | UTF-8 | 4,798 | 3.140625 | 3 | [] | no_license | #![allow(dead_code)]
use color::Color;
use std::ops;
use std::fmt;
use rand;
use rand::distributions::{Range, IndependentSample};
use rand::{IsaacRng, SeedableRng, Rng};
use std::iter::repeat;
#[derive(Clone)]
pub struct Board {
size: u8,
cells: Vec<Color>,
}
impl Board {
pub fn uniform(size: u8) -> Bo... | true |
9fb4102754014d5973cbf7645f8d6f002aea7c12 | Rust | egregors/leetrust | /src/solutions/s1528_restore_string.rs | UTF-8 | 1,457 | 3.609375 | 4 | [
"MIT"
] | permissive | /**
* https://leetcode.com/problems/shuffle-string/
*
* Given a string s and an integer array indices of the same length.
*
* The string s will be shuffled such that the character at the ith
* position moves to indices[i] in the shuffled string.
*
**/
#[allow(dead_code)]
struct Solution {}
#[allow(dead_code)]
... | true |
4eb966ece1b7fece26544c17c8c320f528ebb9ac | Rust | kerinin/email-rs | /src/util.rs | UTF-8 | 5,709 | 2.96875 | 3 | [] | no_license | use std::fmt::Debug;
use std::str::FromStr;
use chomp::*;
use chomp::types::*;
use chomp::parsers::*;
use chomp::combinators::*;
use chomp::primitives::Primitives;
use chomp::primitives::IntoInner;
// use chomp::combinators::bounded;
pub fn unchecked_string_from_bufs<I: U8Input>(bufs: Vec<I::Buffer>) -> String {
... | true |
e321346827f84284bae62570a571174edf5c6866 | Rust | ia7ck/competitive-programming | /AtCoder/ABC204/d/src/main.rs | UTF-8 | 784 | 2.8125 | 3 | [] | no_license | use procon_reader::ProconReader;
fn main() {
let stdin = std::io::stdin();
let mut rd = ProconReader::new(stdin.lock());
let n: usize = rd.get();
let t: Vec<usize> = rd.get_vec(n);
macro_rules! chmin {
($a: expr, $b: expr) => {
$a = std::cmp::min($a, $b);
};
}
... | true |
a466fede8ba7f6f8bf0b83b0ab2d66e4ca97e097 | Rust | greenaddress/electrs | /src/signal.rs | UTF-8 | 861 | 2.703125 | 3 | [
"MIT"
] | permissive | use chan;
use chan_signal;
use std::time::Duration;
use crate::errors::*;
#[derive(Clone)] // so multiple threads could wait on signals
pub struct Waiter {
signal: chan::Receiver<chan_signal::Signal>,
}
impl Waiter {
pub fn new() -> Waiter {
Waiter {
signal: chan_signal::notify(&[chan_sig... | true |
f00355e3b88fe2f500bcc13c8977a5507a845c39 | Rust | 5l1v3r1/witter | /backend/src/tests/login.rs | UTF-8 | 1,813 | 2.859375 | 3 | [] | no_license | use crate::tests::test_helpers::*;
#[async_std::test]
async fn logging_in_without_auth_header() {
let mut server = test_setup().await;
create_user_and_authenticate(&mut server, None).await;
let res = get("/me").send(&mut server).await;
assert_eq!(res.status(), 400);
let content_type = res
... | true |
d391cbc23e51f2026977bb0abd787d2ca9f2deb5 | Rust | ithinuel/hackerrank_rust | /sherlock_and_the_valid-string/src/main.rs | UTF-8 | 2,621 | 3.5 | 4 | [
"MIT"
] | permissive | use std::error;
use std::io;
fn read_line() -> io::Result<String> {
let mut result = String::new();
io::stdin().read_line(&mut result)?;
Ok(result)
}
fn is_valid(s: &str) -> bool {
let mut counter = vec![0; (b'a'..=b'z').count()];
for ch in s.as_bytes() {
let idx = (*ch) - b'a';
co... | true |
71d8abb6b959a162e01e9c90d0eeacb67a788254 | Rust | sidvishnoi/leetcode-rust | /0062-unique-paths.rs | UTF-8 | 824 | 3.15625 | 3 | [] | no_license | struct Solution;
impl Solution {
// same as: ((m-1)+(n-1))! / ((m-1)! * (n-1)!)
// or, (right + down)! / right! * down!
//
// nCk = n! / ((n-k)! * k!)
// = [n * (n-1) *....* 1] / [ ( (n-k) * (n-k-1) * .... * 1) * ( k * (k-1) * .... * 1 ) ]
// = [n * (n-1) * .... * (n-k+1)] / [k * (... | true |
14aa4c35d45cd44b895560910d5be0dec9164030 | Rust | any35/wechat4rs | /example/src/main.rs | UTF-8 | 5,357 | 2.796875 | 3 | [] | no_license | use actix_web::{
get, post,
web::{self, Bytes, Data, Path, Query},
App, HttpResponse, HttpServer, Responder, Result,
};
use async_trait::async_trait;
use log::info;
use wechat4rs::{
errors::{WechatEncryptError, WechatError},
CallbackMessage, EchoStrReq, MessageInfo, ReplyMessage, SaasContext, Verify... | true |
708aa371435b0d975c3637f73fd1f5b1b63706db | Rust | mathieuguyot/advent_of_code_2015 | /src/problem_4.rs | UTF-8 | 1,154 | 3.296875 | 3 | [] | no_license | use std::fs;
use md5;
pub fn run_problem_4() {
let file_name = "data/problem_4.txt";
let file_content = fs::read_to_string(file_name)
.expect(&format!("Cannot open file \"{}\"", file_name));
let part_1_res : u64 = find_index_hash(&file_content, "00000");
let part_2_res : u64 = find_index_hash(... | true |
eccedd18b3d627ed89d360fab2771cc888be6c7b | Rust | alexander-akhmetov/mos | /src/sys/elf/mod.rs | UTF-8 | 2,048 | 2.765625 | 3 | [] | no_license | use crate::multitasking::scheduler;
#[derive(Default)]
#[repr(packed)]
pub struct ELFHeader {
magic: [u8; 4],
class: u8,
endianness: u8,
version: u8,
os_abi: u8,
abi_version: u8,
unused: [u8; 7],
elf_type: u16,
machine: u16,
version2: u32,
pub entry_point: u64,
pub phoff... | true |
41bf2dd22b21d2c88aeb418cd0a0c27ea55e4e62 | Rust | d3v3l0/gitweb | /src/main.rs | UTF-8 | 7,020 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | extern crate git2;
extern crate open;
extern crate regex;
extern crate structopt;
use regex::Regex;
use std::env;
use std::io::Result;
use std::process::exit;
use std::process::{Child, Command};
use structopt::StructOpt;
mod git;
mod logger;
mod options;
/// Function to open the browser using the system shell.
fn op... | true |
7b31efa28cb0acfaa8e0027c229c0a6f9f7d4f65 | Rust | SimonMattei/SEC_Projet | /src/db/utils.rs | UTF-8 | 2,070 | 2.78125 | 3 | [] | no_license | use lazy_static::lazy_static;
use read_input::prelude::*;
use regex::Regex;
use zxcvbn::zxcvbn;
lazy_static! {
static ref EMAIL_RE: Regex =
Regex::new(r"^(?i)[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$").unwrap();
static ref NAME_RE: Regex = Regex::new(r"^[a-zA-Zàâçéèêëîïôûùüÿñæœ .-]{2,20}$").unwrap();
}
... | true |
db51b49d9ade3afdc0a9468222815a52de58455d | Rust | Andrepuel/rudoku | /src/notify.rs | UTF-8 | 1,067 | 2.53125 | 3 | [] | no_license | use crate::rudoku::{Observed, ObservedExt, StateValue};
use notify::{raw_watcher, RawEvent, RecommendedWatcher, RecursiveMode, Watcher};
use std::sync::mpsc::{channel, Receiver};
pub struct WatchFile {
_watcher: RecommendedWatcher,
receiver: Receiver<RawEvent>,
value: StateValue<()>,
}
impl WatchFile {
... | true |
bd294908ef595bff420a7bc16e7e4409c21ad46b | Rust | crystalline/crustacean-irc | /src/main.rs | UTF-8 | 5,750 | 2.75 | 3 | [] | no_license | #![allow(non_snake_case)]
extern crate regex;
use regex::Regex;
use std::net::Ipv4Addr;
use std::str::*;
use std::net::TcpStream;
use std::io::*;
use std::io::{self, BufReader};
use std::thread;
use std::time;
use std::sync::mpsc::channel;
use std::boxed::Box;
static DEBUG: bool = true;
struct IrcClient {
server... | true |
4cdebba89791f3547b4d445aedcdb65b52e960de | Rust | LordMZTE/miette | /tests/graphical.rs | UTF-8 | 21,191 | 2.71875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #![cfg(feature = "fancy")]
use miette::{
Diagnostic, GraphicalReportHandler, GraphicalTheme, MietteError, NamedSource,
NarratableReportHandler, Report, SourceSpan,
};
use thiserror::Error;
fn fmt_report(diag: Report) -> String {
let mut out = String::new();
// Mostly for dev purposes.
if std::env:... | true |
490fb1cf5fc65509e597cf9e5cae70c13b1851ce | Rust | Jvanrhijn/mole | /scripts/statfor.rs | UTF-8 | 3,096 | 3.46875 | 3 | [] | no_license | use std::vec::Vec;
use std::io::{self, BufRead, Write, Result};
use std::fs::File;
/// Read a stream of data from stdin line by line
fn read_data() -> Result<Vec<f64>> {
let stdin = io::stdin();
let data = stdin.lock().lines()
.map(|x| x.unwrap().split_whitespace().collect::<Vec<_>>()[0]
... | true |
f06a3a988f587c07a013470b4ff8cfe99f220274 | Rust | gf712/learn | /rust/data_structures/src/lib.rs | UTF-8 | 4,780 | 3.671875 | 4 | [] | no_license | mod data_structures {
#[derive(Debug)]
struct Node<'a, T> {
data: &'a T,
next_node: Option<Box<Node<'a, T>>>,
}
pub struct LinkedList<'a, T> {
front: Option<Box<Node<'a, T>>>,
}
impl<'a, T: std::fmt::Debug> LinkedList<'a, T> {
pub fn new() -> LinkedList<'a, T> {... | true |
9d81beb01ba66d6f7a9bcccdbc88265bb84f0990 | Rust | vks16/rust-random | /src/main.rs | UTF-8 | 1,335 | 3.875 | 4 | [] | no_license | use rand::thread_rng;
use rand::Rng;
fn main() {
// let i : i32 = rand::random();
// println!("The random i32 is {} ", i);
// let x: u8 = rand::random();
// println!("The random u8 is {}", x);
// let x: f64 = rand::random();
// println!("The random f64 is {}", x);
// let x:bool = rand::r... | true |
fcd9431b2b9b3bc2770fded85672e03d24059c19 | Rust | tronje/dir-prompt-helper | /src/main.rs | UTF-8 | 1,313 | 3.3125 | 3 | [] | no_license | use std::process::Command;
fn whoami() -> String {
let output = Command::new("whoami")
.output()
.expect("Failed to run 'whoami'!");
String::from_utf8(output.stdout)
.unwrap()
.trim()
.to_owned()
}
fn pwd() -> String {
let output = Command::new("pwd")
.ar... | true |
81518723de77ae326a64c24700329b9c3e48bdcc | Rust | AndreiNet/advent_of_code_2019 | /9/src/main.rs | UTF-8 | 8,110 | 3.03125 | 3 | [] | no_license | extern crate num_bigint;
extern crate num_traits;
mod errors;
use std::str::FromStr;
use std::collections::HashMap;
use num_bigint::BigInt;
use num_traits::cast::ToPrimitive;
fn str_to_numbers(s: &str) -> Vec<BigInt> {
s.split(',')
.filter(|s| s.trim() != "")
.map(|s| BigInt::from_str(s.trim()).... | true |
02c0844819332a620acf0fb2e45818118475cfeb | Rust | lindblom/rustycloud | /src/main.rs | UTF-8 | 670 | 2.765625 | 3 | [] | no_license | use warp::http::header::HeaderValue;
use warp::Filter;
use std::env;
#[tokio::main]
async fn main() {
let port = env::var("PORT")
.unwrap_or("3030".into())
.parse::<u16>()
.expect("Port env var not set to a valid u16");
// GET /hello/warp => 200 OK with body "Hello, warp!"
let hell... | true |
6f0e5d0397a045f85503cf4c11067eba67934743 | Rust | shulcsm/dokku-pg | /src/config.rs | UTF-8 | 940 | 2.828125 | 3 | [] | no_license | extern crate toml;
use std;
use std::io::prelude::*;
use std::fs::File;
#[derive(Debug)]
pub enum Error {
FileReadError,
TomlError
}
impl From<std::io::Error> for Error {
fn from(_err: std::io::Error) -> Error {
Error::FileReadError
}
}
#[derive(Deserialize, Debug)]
pub struct Config {
... | true |
21ffceca169bc984a8af5247256c40361d1a7aef | Rust | Airtnp/collection_traits | /src/misc.rs | UTF-8 | 8,981 | 3.171875 | 3 | [
"MIT"
] | permissive | use crate::{
elem::{AssociatedCollectionTrait, CollectionTrait, Owned},
exact_size::ExactSized,
};
use std::hint::unreachable_unchecked;
/// Collections that can construct `Self` without data.
pub trait EmptyConstructible {
/// Construct `Self` without data.
fn new() -> Self
where
Self: Own... | true |
b2cfc9b3d54c451ccdbb54c4b69516cfe7f1439f | Rust | xpe/rs_bandit_testbed | /src/action.rs | UTF-8 | 186 | 2.84375 | 3 | [] | no_license | /// Action (both the arm chosen and the ensuing reward)
#[derive(Clone, Debug)]
pub struct Action {
/// The chosen arm
pub arm: usize,
/// The reward
pub reward: f64,
}
| true |
4e7cfe2e2a5e8910c883ed535a8bc7b4839da75c | Rust | AlecDivito/rustbitmap | /src/bitmap/file.rs | UTF-8 | 6,195 | 3.140625 | 3 | [
"MIT"
] | permissive | use super::bit_depth::BitDepth;
use super::file_data::FileData;
use super::file_header::FileHeader;
use super::image::BitMap;
use super::info_header::InfoHeader;
use super::rgb_quad::RgbQuad;
use super::rgba::Rgba;
pub struct File {
file: FileHeader,
info: InfoHeader,
colors: RgbQuad,
data: FileData,
}... | true |
609afba31ba1010e19faf8515443109e56046e96 | Rust | shazow/vr-rs | /examples/test.rs | UTF-8 | 2,357 | 2.703125 | 3 | [] | no_license | extern crate vr;
fn print_matrix_4x4(offset: u32, mat: [[f32; 4]; 4]) {
let off: String = (0..offset).map(|_| ' ').collect();
println!("{:?}", mat[0]);
println!("{}{:?}", off, mat[1]);
println!("{}{:?}", off, mat[2]);
println!("{}{:?}", off, mat[3]);
}
fn print_matrix_4x3(offset: u32, mat: ... | true |
8b93a1f0a62583940ef10b995379938b992840d9 | Rust | torkeldanielsson/pe | /pe_14/src/main.rs | UTF-8 | 852 | 3 | 3 | [] | no_license | use std::collections::HashMap;
fn main() {
let mut map = HashMap::new();
let mut res = 0;
for i in 1..1000000 {
let mut len = 1;
let mut c: i64 = i as i64;
while c != 1 {
// print!("{}->", c);
len += 1;
if c % 2 == 0 {
c = c/2;
... | true |
c964f0221de4afb9a241b501e011cda3854e8571 | Rust | mdinger/gfx-rs | /src/device/gl/mod.rs | UTF-8 | 20,876 | 2.625 | 3 | [] | no_license | // Copyright 2014 The Gfx-rs Developers.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... | true |
d51592b385648c9581bc1a27a6c716d7cd366324 | Rust | 0xb10ckdev/forest | /src/utils/db/car_index/slot.rs | UTF-8 | 2,071 | 2.765625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2019-2023 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use super::{FrameOffset, Hash, KeyValuePair};
use std::io::{Read, Result};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(test, derive(derive_quickcheck_arbitrary::Arbitrary))]
pub enum Slot {
Empty,
Full(KeyValuePai... | true |
e1c7a63c3da9f048034521383abe15ee742cafd3 | Rust | debragail/prisma-engines | /migration-engine/core/src/commands/mark_migration_rolled_back.rs | UTF-8 | 2,739 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | use crate::{CoreError, CoreResult};
use migration_connector::MigrationConnector;
use serde::Deserialize;
use std::collections::HashMap;
use user_facing_errors::migration_engine::{CannotRollBackSucceededMigration, CannotRollBackUnappliedMigration};
/// The input to the `markMigrationRolledBack` command.
#[derive(Debug,... | true |
db72d571a7eeb9f7b5212698dec5c55e015fcfef | Rust | mashtizadeh/wasmtime | /cranelift/codegen/src/legalizer/boundary.rs | UTF-8 | 41,322 | 2.75 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | //! Legalize ABI boundaries.
//!
//! This legalizer sub-module contains code for dealing with ABI boundaries:
//!
//! - Function arguments passed to the entry block.
//! - Function arguments passed to call instructions.
//! - Return values from call instructions.
//! - Return values passed to return instructions.
//!
/... | true |
c1e176844c85e283c37bbcf88902f53e35bb67b5 | Rust | c-bata/bloomfilter | /src/lib.rs | UTF-8 | 1,499 | 3.578125 | 4 | [] | no_license | use bit_vec::BitVec;
#[derive(Debug)]
pub struct BloomFilter {
buf: BitVec,
m: usize
}
fn h1(key: usize, m: usize) -> usize {
return key % m
}
fn h2(key: usize, m: usize) -> usize {
return (key * 2) % m
}
impl BloomFilter {
pub fn new(m: usize) -> BloomFilter {
let buf = BitVec::from_ele... | true |
17afe9f70fa89d10f2da1001993628904b087ab5 | Rust | Askannz/icosphere | /src/camera.rs | UTF-8 | 1,148 | 2.734375 | 3 | [] | no_license | use three::object::Object;
const R_INIT: f32 = 3.0;
const ZOOM_RATE: f32 = 0.1;
pub struct Camera {
pub three_camera: three::camera::Camera,
r: f32,
smooth_r : f32
}
impl Camera {
pub fn new(three_factory: &mut three::Factory) -> Camera {
let three_camera = three_factory.perspective_camera(... | true |
351f19d59067c794888769f97154942db2160ec5 | Rust | marco-c/gecko-dev-wordified-and-comments-removed | /third_party/rust/hex/src/error.rs | UTF-8 | 1,240 | 2.96875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use
core
:
:
fmt
;
#
[
derive
(
Debug
Clone
Copy
PartialEq
)
]
pub
enum
FromHexError
{
InvalidHexCharacter
{
c
:
char
index
:
usize
}
OddLength
InvalidStringLength
}
#
[
cfg
(
feature
=
"
std
"
)
]
impl
std
:
:
error
:
:
Error
for
FromHexError
{
}
impl
fmt
:
:
Display
for
FromHexError
{
fn
fmt
(
&
self
f
:
&
mut
fmt
:
... | true |
72871af542daaa2f2c7daf24ad7d552b8b2cad34 | Rust | BlueJWay/Programming_Languages_Final_Assignment_BF | /tests/test_parser.rs | UTF-8 | 2,092 | 3.671875 | 4 | [] | no_license |
#[cfg(test)]
extern crate interpreter;
pub use interpreter::expression::*;
pub use interpreter::evaluator::*;
pub use interpreter::environment::*;
pub use interpreter::lexer::*;
pub use interpreter::parser::*;
mod parser_test {
use super::*;
#[test]
fn parser_exists(){
assert_eq!(1, 1);
}
... | true |
a5925d6415b112a00c4a9be90b95c25fb4be749c | Rust | Daan4/hv-network-visualizer | /src/position.rs | UTF-8 | 1,603 | 3.6875 | 4 | [
"MIT"
] | permissive | #[derive(PartialEq)]
enum SwitchPosition {
Open,
Close,
}
/// Switchgear Position
pub struct SwitchgearPosition {
position: SwitchPosition,
}
impl SwitchgearPosition {
/// Constructor
pub fn new() -> SwitchgearPosition {
SwitchgearPosition {
position: SwitchPosition::Open,
... | true |
1c6b887c3c21771184066c3fc485c76d81935b37 | Rust | AraragiRukasu/rust-tree | /src/main.rs | UTF-8 | 862 | 2.859375 | 3 | [] | no_license | extern crate tree;
use tree::TreeNode;
fn main() {
let node1 = TreeNode::<i32>::new(1);
let node2 = TreeNode::new(2);
let node3 = TreeNode::new(3);
let node4 = TreeNode::new(4);
let node5 = TreeNode::new(5);
let node6 = TreeNode::new(6);
let node7 = TreeNode::new(7);
let node8 = TreeNo... | true |
66bdda199c779f5d05665b1ddaf82e280b471abb | Rust | expenses/war-against-machines | /src/context/audio.rs | UTF-8 | 1,231 | 2.921875 | 3 | [
"MIT"
] | permissive | // Audio Playback
use resources::AUDIO;
use rodio::*;
use std::io::Cursor;
use std::rc::Rc;
// An audio player struct
pub struct Player {
sources: Vec<Rc<Vec<u8>>>,
sinks: Vec<Sink>,
endpoint: Device,
}
impl Player {
pub fn new() -> Player {
Player {
// Use reference-counting to... | true |
b091698ca048432663cc9ff079c66e65e6018ccf | Rust | Adenilson/rust-openssl | /openssl/src/ssl/error.rs | UTF-8 | 3,337 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | pub use self::SslError::*;
pub use self::OpensslError::*;
use libc::c_ulong;
use std::error;
use std::fmt;
use std::ffi::c_str_to_bytes;
use std::old_io::IoError;
use ffi;
/// An SSL error
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SslError {
/// The underlying stream reported an error
StreamError(IoErr... | true |
71fe9e94aef76a776d84a6cadd5a76105528a99c | Rust | TTcheng/LearnRust | /tests/src/adder.rs | UTF-8 | 101 | 2.65625 | 3 | [] | no_license | pub fn add_two(num:i32) -> i32{
num + 2
}
fn internal_adder(a: i32, b: i32) -> i32 {
a + b
} | true |
622e2d026304f739ec5d6ceae11bd1d794605e14 | Rust | uuhan/luster | /src/string.rs | UTF-8 | 3,429 | 2.96875 | 3 | [] | no_license | use std::borrow::Borrow;
use std::hash::{Hash, Hasher};
use std::io::Write;
use std::ops::Deref;
use failure::{err_msg, Error};
use rustc_hash::FxHashSet;
use gc_arena::{Collect, Gc, GcCell, MutationContext};
use crate::value::Value;
#[derive(Debug, Copy, Clone, Collect)]
#[collect(require_copy)]
pub enum String<'g... | true |
ac2c8819dc291b7f052304cfd0be1e619cac2433 | Rust | theryangeary/vizz | /examples/my_struct_derive.rs | UTF-8 | 718 | 3.578125 | 4 | [] | no_license | //! Example demonstrating how to derive the trait `Visualize` for a struct, and use it to generate
//! a DOT file.
use std::error::Error;
use std::fs::File;
use vizz::{Graph, Visualize};
#[derive(Visualize)]
struct MyStruct<'a> {
my_u8: u8,
my_string: String,
my_ref: &'a String,
}
pub fn main() -> Resul... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.