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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
0216d1361436bb84e46995e99b88a24f0e8a5d20 | Rust | GuillaumeGomez/c_vec-rs | /src/c_slice.rs | UTF-8 | 13,184 | 3.296875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2012 The Rust Project Developers.
// Copyright 2015 Guillaume Gomez
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copie... | true |
2518d909a646af77e8f88419c2fe18c356e68360 | Rust | SuperFluffy/telamon | /src/explorer/candidate.rs | UTF-8 | 3,004 | 2.890625 | 3 | [] | no_license | //! Exploration of the search space.
use device::Context;
use explorer::choice::ActionEx;
use rpds::List;
use model::{bound, Bound};
use search_space::SearchSpace;
use std::cmp::{Ordering, PartialOrd};
use std;
use itertools::Itertools;
/// A node of the search tree.
#[derive(Clone)]
pub struct Candidate<'a> {
/... | true |
c7d4895fa89d13430aca4c04d3fbeb3eef60c855 | Rust | tomberek/advent-2020 | /src/day07.rs | UTF-8 | 2,882 | 2.84375 | 3 | [] | no_license | #![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unreachable_code)]
#![allow(unused_imports)]
use aoc_runner_derive::{aoc, aoc_generator};
use scan_fmt::scan_fmt_some;
use rayon::prelude::*;
use std::collections::HashMap;
use std::collections::HashSet;
use nohash_hasher::{IntSet,IntMap};
#[aoc_generator(day... | true |
100b90a8385ac8ccc647b529b5681d3da52665a9 | Rust | casey/office-hours | /misc/src/option.rs | UTF-8 | 555 | 3.359375 | 3 | [] | no_license | // enum Option<T> {
// Some(T),
// None,
// }
pub fn main() {
let x = Some(100); // Option<i64>
let mut y: Option<&str> = None; // Option<&str>
dbg!(x);
dbg!(y);
y = Some("hello");
dbg!(y);
let v: Option<Vec<u64>> = Some(vec![1,2,3]);
dbg!(&v);
let xp: *const Option<_> = &x;
let yp: *const Opt... | true |
64545c4ba1fe62d21dea01c659a25ef806d82e9d | Rust | JamesShoaf/AlgorithmPractice | /contests/LeetCode/2020/2020-10-10LeetCode/count_subgraphs_for_each_diameter/src/lib.rs | UTF-8 | 1,138 | 3.296875 | 3 | [] | no_license | /*
There are n cities numbered from 1 to n. You are given an array edges of size n-1, where
edges[i] = [ui, vi] represents a bidirectional edge between cities ui and vi. There exists a unique
path between each pair of cities. In other words, the cities form a tree.
A subtree is a subset of cities where every city is ... | true |
0b306ee08831ef74c2186b14d43d6e09902787aa | Rust | rustbasic-arch/rust_smart_pointer | /force-deref-call-property/src/main.rs | UTF-8 | 540 | 3.53125 | 4 | [
"MIT"
] | permissive | use std::ops::Deref;
struct MyWrapBox<T>{
value:T
}
impl<T> MyWrapBox<T>{
fn new(value:T)->Self{ //这里就是Box的实现,这里会发生move ,除非value 实现了copy
MyWrapBox{
value
}
}
}
impl<T> Deref for MyWrapBox<T>{
type Target = T;
fn deref(&self)->&T{
&self.value
}
}
type Nam... | true |
89e51baf414c2b1d07169d657b44700b2431ac8d | Rust | bostonbell/SzismR | /src/parser/arg_parse.rs | UTF-8 | 5,602 | 3.0625 | 3 | [] | no_license | /*
* Allows us to parse our arguments into a noun verb adjetive structure.
*/
pub mod argument_parser{
use regex::Regex;
use std::env;
use std::collections::HashSet;
//Verb -> Noun* || Flag* || EOP -> Flag* || EOP
pub enum ParseState{
SOP,
Verb(String),
Noun(String),
... | true |
1bfb5505d7ab8a04398c4a31525990a24361a34e | Rust | jimmyhmiller/PlayGround | /rust/hydroxide/src/main.rs | UTF-8 | 7,195 | 3.578125 | 4 | [] | no_license | use std::str::from_utf8;
// I could do this without allocating
#[derive(Debug, Clone)]
pub enum Token {
Tag(Vec<Token>),
Variable(Vec<Token>),
Identifier(String),
String(String),
Dot,
Pipe,
Colon,
Other(String),
}
#[derive(Debug, Clone)]
pub struct Tokenizer {
pub position: usi... | true |
a31231655d38eb6673c0c96eca46f91794e04bdf | Rust | giggio/iluria-export | /src/args.rs | UTF-8 | 9,962 | 3.015625 | 3 | [
"MIT"
] | permissive | use std::path::Path;
use clap::{App, AppSettings, Arg};
#[derive(Debug)]
pub struct Args {
pub verbose: bool,
pub file: String,
pub url: String,
pub limit: u32,
pub output_dir: Option<String>,
pub output_products_file: String,
pub output_variations_file: String,
pub force: bool,
pu... | true |
e0411303196a7f2305ea068fa5b288bdb13247e8 | Rust | appcypher/wasmo | /runtime/lib/api/instance.rs | UTF-8 | 788 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | use super::Store;
use crate::compiler::value::Value;
use crate::{Imports, Module};
use anyhow::Result;
/// An Instance is a fully resolved wasm runtime context.
/// External references (globals, functions, memories, tables) are resolved.
/// And memories and tables have been created.
#[derive(Debug, Default)]
pub stru... | true |
b2d7e33eb94bd38b42a958d61ca5d90cc9faee02 | Rust | daiyanbao/tun2tor | /socks/src/response.rs | UTF-8 | 3,681 | 2.625 | 3 | [] | no_license | use std::io::{self, Read, Cursor};
use libc::{ENETUNREACH, EHOSTUNREACH, ECONNREFUSED};
use version::Version;
use address::Address;
use result::{Result, Error};
const SOCKS4_STATUS_GRANTED: u8 = 0x5A;
const SOCKS4_STATUS_FAILED: u8 = 0x5B;
const SOCKS4_STATUS_NOT_RUNNING_IDENTD: u8 = 0x5C;
const SOCKS4_STATUS_INCORRE... | true |
1e64c8eae0496b59868ab814dfcf63d72f6fc3e1 | Rust | fukatani/rust-ant-book | /src/euclid_game.rs | UTF-8 | 424 | 3.375 | 3 | [] | no_license | fn main() {
let mut a = 34;
let mut b = 12;
let mut stan_win = true;
loop {
if a > b {
std::mem::swap(&mut a, &mut b);
}
if b % a == 0 {
break;
}
if b > 2 * a {
break;
}
b -= a;
stan_win = !stan_win;
... | true |
be843ed2ddeaa385bab90e50dd401788a12f765a | Rust | kamioftea/advent-of-code-2020 | /src/day_5.rs | UTF-8 | 2,680 | 3.546875 | 4 | [] | no_license | use std::fs;
use std::collections::HashSet;
#[derive(Debug, Eq, PartialEq)]
struct Seat { id: usize }
impl Seat {
fn from_line(line: &str) -> Seat {
Seat {
id: line.chars().fold(
0,
|acc, char| (acc << 1) | match char {
'F' | 'L' => 0b0,
... | true |
e906e267e3898b164ad281d2af30bb915faa85d2 | Rust | liamom/c_game | /tmx_parser/src/tile_error.rs | UTF-8 | 559 | 2.859375 | 3 | [] | no_license | use std::num::ParseFloatError;
use std::str::ParseBoolError;
use std::num::ParseIntError;
#[derive(Debug)]
pub enum TMXError {
Float(ParseFloatError),
Bool(ParseBoolError),
Int(ParseIntError),
}
impl From<ParseFloatError> for TMXError {
fn from(t: ParseFloatError) -> Self {
TMXError::Float(t)
... | true |
82300a4656da09b011889ef1a221ce4494e7daf2 | Rust | jamiebrynes7/aoc-2020 | /src/bin/day07.rs | UTF-8 | 3,042 | 2.984375 | 3 | [] | no_license | use std::{collections::HashMap, collections::HashSet, str::FromStr};
use anyhow::{Context, Result};
use aoc_2020::input_lines;
use lazy_static::lazy_static;
use regex::Regex;
fn main() -> Result<()> {
let input = input_lines(7)?
.map(|line| {
let line = line.context("Failed to read line")?;
... | true |
22500e8745187e2ec78e553f488ad94cf4a79b24 | Rust | Daniel-Bloom-dfinity/atomic-option-cell | /src/fallback.rs | UTF-8 | 4,533 | 3.234375 | 3 | [
"Apache-2.0"
] | permissive | use core::marker::PhantomData;
#[cfg(feature = "std")]
use std::sync::{Mutex, RwLock};
use array_macro::array;
use lazy_static::lazy_static;
/// Provides the necessary locking operations in case atomics aren't available
pub trait FallbackLock: Sync {
/// Implementations should:
/// * check if an optimistic re... | true |
022278a3045c9563aba9835912c2939b57bdc8c9 | Rust | lecrepuscule/Rust-collections | /src/pig_latin.rs | UTF-8 | 552 | 3.15625 | 3 | [] | no_license | pub fn pig_latin(input_string: &String) -> String {
let vowels = ['a', 'e', 'i', 'o', 'u'];
let mut pig_latin_string = String::new();
let mut pig_latin_suffix = String::from("-");
for (i, c) in input_string.chars().enumerate() {
if i == 0 {
match vowels.iter().position(|&s| s == c) {
None => {
pig_la... | true |
ea81d335ef9fde4c130e4b56501abebd0bc4cb59 | Rust | bumzack/nvptx | /examples/rgba2gray.rs | UTF-8 | 4,513 | 2.765625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Convert a color image to grayscale
extern crate cuda;
extern crate image;
use std::ops::Add;
use std::time::{Duration, Instant};
use std::ffi::{CStr, CString};
use std::fs::File;
use std::io::Read;
use std::{env, mem};
use cuda::driver::{Any, Block, Device, Direction, Grid, Result};
use cuda::driver;
use image::... | true |
74cdbf5c42e08edbf44f06393326115d0819b98c | Rust | wolenber/puccinia | /src/objects/stream.rs | UTF-8 | 1,389 | 3.375 | 3 | [] | no_license | use super::PdfDictionary;
use super::PdfInteger;
use super::PdfObject;
use output::Output;
/// A PDF stream
#[derive(Debug)]
#[derive(Clone)]
pub struct PdfStream {
contents: Vec<String>,
length: usize
}
impl PdfStream {
/// Create a new stream
pub fn new() -> PdfStream {
PdfStream {
... | true |
405b4b292b0a8013e44bfb9e67e2551252343389 | Rust | cshaffer/advent_2017 | /src/main.rs | UTF-8 | 2,096 | 2.875 | 3 | [] | no_license | mod checksum;
mod io;
mod inverse_captcha;
mod jump;
mod passphrase;
mod tower;
mod realloc;
mod spiral_memory;
mod registers;
mod stream;
mod knot;
fn inverse_captcha_main() {
let sum = inverse_captcha::inverse_captcha(io::read_one_line());
println!("Sum: {}", sum);
}
fn checksum_main() {
let numbers = i... | true |
ac8d344c6f477ee6639c0f24f4c845c0fb0f6dd7 | Rust | jacobjonsson/wlang | /leg/lexer/src/lib.rs | UTF-8 | 4,644 | 3.5625 | 4 | [] | no_license | mod token_kind;
use logos::Logos;
use std::ops::Range as StdRange;
use text_size::{TextRange, TextSize};
pub use token_kind::TokenKind;
pub struct Lexer<'a> {
inner: logos::Lexer<'a, TokenKind>,
}
impl<'a> Lexer<'a> {
pub fn new(input: &'a str) -> Lexer {
Lexer {
inner: TokenKind::lexer(i... | true |
7d3e9855ba1dd2f0cb2f1cac11cdf0b07a3bbb68 | Rust | bitonic/puzzlescript-rs | /core/src/game.rs | UTF-8 | 9,411 | 2.78125 | 3 | [] | no_license | use crate::ast;
use crate::grid::*;
use im_rc::hashmap as im_hashmap;
use serde_derive::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::fmt::{Display, Formatter};
use std::rc::Rc;
pub use self::ast::{Object, ObjectName, Prelude, PropertyName, RuleCommand, SoundFx};
#[derive(... | true |
fe1a7e83ebec18d862f3aaa4357b3647219bf890 | Rust | laysakura/pgx-kungfu | /my_extension/src/host/integer_avg/typ.rs | UTF-8 | 753 | 3.03125 | 3 | [] | no_license | use pgx::*;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, PostgresType)]
pub struct IntegerAvgState {
sum: i32,
n: i32,
}
impl Default for IntegerAvgState {
fn default() -> Self {
Self { sum: 0, n: 0 }
}
}
impl IntegerAvgState {
pub fn acc(&self, v: i32) -> Self {
... | true |
c619716888a8b13101658c1d9a22aedcb5e85926 | Rust | fitzgen/minisynth-rs | /src/ast.rs | UTF-8 | 1,338 | 3.109375 | 3 | [] | no_license | use id_arena::{Arena, Id};
use std::collections::HashMap;
#[derive(Default)]
pub struct Context {
idents: Arena<String>,
already_interned: HashMap<String, StringId>,
nodes: Arena<Node>,
}
pub type StringId = Id<String>;
pub type NodeId = Id<Node>;
pub enum Node {
Identifier(StringId),
Addition(No... | true |
d0b1a3eaf73aa260b1056bd73e7ee2c36e9ce1e8 | Rust | blueluna/psila | /psila-crypto-rust-crypto/src/lib.rs | UTF-8 | 5,965 | 2.546875 | 3 | [
"MIT"
] | permissive | #![no_std]
use psila_crypto::{CryptoBackend, Error, BLOCK_SIZE};
use aes::{
Aes128,
cipher::{BlockEncrypt, NewBlockCipher}
};
use ccm::{
aead::{generic_array::GenericArray, AeadInPlace, NewAead},
consts::{U13, U16, U4, U8},
Ccm,
};
#[cfg(test)]
mod test;
type AesCcmMic4 = Ccm<Aes128, U4, U13>;
... | true |
cea38f0daba5997a234e8cbfed4e64bd7294e20a | Rust | johnellis1392/programming_problems | /leetcode/rust/src/tree.rs | UTF-8 | 458 | 3.046875 | 3 | [] | no_license | use std::rc::Rc;
use std::cell::RefCell;
pub type Tree = Option<Rc<RefCell<TreeNode>>>;
#[derive(Debug, PartialEq, Eq)]
pub struct TreeNode {
pub val: i32,
pub left: Tree,
pub right: Tree,
}
pub fn leaf(val: i32) -> Tree {
Some(Rc::new(RefCell::new(TreeNode {
val,
left: None,
right: None,
})))
... | true |
2aaa21612d4d5af03cbb2de7694e269d2ee4a444 | Rust | himkt/problems | /atcoder/src/bin/agc022_a.rs | UTF-8 | 2,973 | 3.078125 | 3 | [] | no_license | const ALPHABET: [char; 26] = [
'a', 'b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y',
'z',
];
#[allow(clippy::nonminimal_bool)]
fn len_descent(s: &Vec<char>) -> usize {
let mut ret = 1;
let n: usize = s.len();
for... | true |
06b84ced9e06d3c89a2f1699c2e1c9dd0827e569 | Rust | nginxinc/ngx-istio-mixer | /mixer-transport/src/transport/status_test.rs | UTF-8 | 364 | 2.75 | 3 | [
"Apache-2.0"
] | permissive |
use super::status::{ Status, StatusCodeEnum };
#[test]
fn test_code_ok() {
let status = Status::new();
assert_eq!(status.get_error_code(), StatusCodeEnum::OK);
}
#[test]
fn test_code_ok_invalid_arg() {
let status = Status::with_code(StatusCodeEnum::INVALID_ARGUMENT);
assert_eq!(status.get_error_... | true |
3e09e4816c512608c9e007753eb4978e02c766bd | Rust | nebula-os/ppk | /src/utils/archive.rs | UTF-8 | 1,370 | 2.78125 | 3 | [] | no_license | use anyhow::Result;
use flate2::read::GzDecoder;
use std::fs::create_dir_all;
use std::fs::File;
use std::path::PathBuf;
use tar::Archive;
pub fn unarchive_tar_gz(file: &PathBuf, to: &PathBuf) -> Result<()> {
// Validation
if file.exists() == false {
return Err(anyhow!("File doesn't exist"));
}
... | true |
ce246f0c331c19591eb377bc8e409e5805eab0a0 | Rust | tengyifei/icfp-universal-machine | /src/um/machine.rs | UTF-8 | 10,565 | 3.296875 | 3 | [] | no_license | use super::errors;
use super::instructions;
use std::collections::HashMap;
use std::io::Read;
/// A platter in the universal machine; a unit of storage.
pub type Word = u32;
pub struct Machine {
finger: Word,
registers: [Word; 8],
program: Vec<Word>,
data_arrays: HashMap<Word, Vec<Word>>,
next_arr... | true |
f38a69643f945db7607e2d0e95e1cdedf5f7967a | Rust | starcoinorg/starcoin | /commons/accumulator/src/tree_store/mock.rs | UTF-8 | 1,773 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{AccumulatorNode, AccumulatorTreeStore};
use anyhow::{bail, Result};
use parking_lot::Mutex;
use starcoin_crypto::HashValue;
use std::collections::HashMap;
pub struct MockAccumulatorStore {
node_store: Mutex<HashMap<... | true |
46117cf92f323753225de1fc955071be12fec120 | Rust | eulegang/aoc-2020 | /day-1/src/lib.rs | UTF-8 | 1,634 | 3.625 | 4 | [] | no_license | use std::num::ParseIntError;
use std::str::FromStr;
pub struct ExpenseReport {
expenses: Vec<usize>,
}
impl ExpenseReport {
pub fn check(&self) -> usize {
for (i, a) in self.expenses.iter().enumerate() {
for n in i + 1..self.expenses.len() {
let b = self.expenses[n];
... | true |
216fc4ba2c51277211cbbc0c3a42ffd587ae5eb9 | Rust | ryanpierson87/rust_pomodoro | /src/main.rs | UTF-8 | 720 | 2.75 | 3 | [] | no_license | mod countdown_clock;
use std::io;
use gtk::gdk;
fn main() {
let minutes = 1;
let mut confirm = String::new();
println!("Press ENTER to begin next phase:");
io::stdin()
.read_line(&mut confirm);
countdown_clock::countdown(minutes, "work");
println!("Press ENTER to begin next phase:");
... | true |
05980c3a64b6fcf8bf4f89d116d261e71d1c8d21 | Rust | Azure/azure-sdk-for-rust | /services/svc/devcenter/src/package_2022_03_01_preview/models.rs | UTF-8 | 43,186 | 2.734375 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT",
"LGPL-2.1-or-later"
] | permissive | #![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::de::{value, Deserializer, IntoDeserializer};
use serde::{Deserialize, Serialize, Serializer};
use std::str::FromStr;
#[doc = "Action request"]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ActionRequest {
#[doc = "The Catal... | true |
a6b12dba4e45131fca3ac6eb2788922b8515165d | Rust | JialuGong/mjava-implementation-in-rust | /crates/mjava_scanner/src/cursor.rs | UTF-8 | 1,526 | 3.5625 | 4 | [
"MIT"
] | permissive | //The curosor is a mini rust-cursor
use std::str::Chars;
///The cursor is a `iterator` of a char sequence
///
///
///
/// # Examples
/// ```rust
/// //create a new cursor
///let cursor=Cursor::new("abc");
/// assert_eq!('a',cursor.first_char());
/// assert_eq!('b',cursor.scond_char());
///
/// ```
///
///
pub struct ... | true |
189c57cf55496faa71be631ecdb549f9c16e4f9e | Rust | Kixiron/graph-asm | /src/types.rs | UTF-8 | 6,562 | 3.265625 | 3 | [] | no_license | use crate::{operator::Operator, EGraph};
use egg::Id;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Type {
Bool,
Int,
UInt,
Unit,
List(Box<Self>),
Tuple(Vec<Self>),
Option(Box<Self>),
Lambda(Vec<Self>, Box<Self>),
Collection(Box<Self>),
Unknown,
}
impl Type {
/// Returns ... | true |
320d0c10a3f027957651797662071ebdfdd8e7f9 | Rust | oliver-giersch/conquer-once | /src/park.rs | UTF-8 | 10,387 | 3.109375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use std::{
cell::Cell,
sync::atomic::{AtomicBool, Ordering},
thread::{self, Thread},
};
use conquer_util::BackOff;
use crate::{
cell::{Block, Unblock},
state::{
AtomicOnceState, BlockedState,
OnceState::{Ready, Uninit, WouldBlock},
},
POISON_PANIC_MSG,
};
use self::interna... | true |
291db5b5335917ac6d0259cfe1dfb71c358099bf | Rust | KarlaJu/Rust_examples | /Project_Euler/Multiples_of_three_and_five/src/main.rs | UTF-8 | 608 | 3.921875 | 4 | [] | no_license | pub fn add(number: i32 ) -> i32 {
//Natural numbers, multiples of 3 or 5
//for (int i = 0; i < 10; i++){
if number % 3 == 0 || number % 5 == 0{
return 0;
}
return 1;
//}
}
#[cfg(test)]
mod tests {
use super::add;
#[test]
fn testing_multiples_of_three() {
let nu... | true |
02e4c5e7ffd4e30aec8f372fcc383427c89fc07a | Rust | nosajio/codex_parser_wasm | /src/lib.rs | UTF-8 | 2,942 | 2.875 | 3 | [] | no_license | extern crate console_error_panic_hook;
extern crate cfg_if;
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
mod process;
use cfg_if::cfg_if;
use chrono::NaiveDate;
use regex::Regex;
use serde::Serialize;
use std::collections::HashMap;
const FILENAME_PTN: &str = r"([a-z0-9-]*)-(\d{4}-\d{2}-\d{2})?.md";
cfg_... | true |
2a327b4e1e2831480c98dce61ca8bbedd9f19632 | Rust | Ogeon/pyrite | /pyrite/src/project/eval_context.rs | UTF-8 | 1,293 | 3.046875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::error::Error;
use super::Nodes;
#[derive(Clone, Copy)]
pub(crate) struct EvalContext<'a> {
pub nodes: &'a Nodes,
}
pub(crate) trait Evaluate<T> {
fn evaluate<'a>(&self, context: EvalContext<'a>) -> Result<T, Box<dyn Error>>;
}
pub(crate) trait EvaluateOr<T> {
fn evaluate_or<'a>(&self, context: ... | true |
0afda160ce80e521b9825c142e7ebe6805406a9e | Rust | ssundarr3/simple-torrent | /src/chan_msg.rs | UTF-8 | 1,044 | 2.828125 | 3 | [
"MIT"
] | permissive | use crate::torrent_msg::TorrentMsg;
use std::net::IpAddr;
use tokio::net::tcp;
#[derive(Debug)]
pub enum ChanMsgKind {
/// A connection has been created with a peer.
NewPeer(tcp::OwnedWriteHalf, IpAddr),
/// Shutdown the connection with the peer.
Shutdown,
/// A torrent message from the peer.
M... | true |
dc06f8d9fa320862fe8041c454eb0bc166b563aa | Rust | faustfu/hello_rust | /src/lif2.rs | UTF-8 | 875 | 3.515625 | 4 | [] | no_license | // 1. structs could have reference types. Their lifetimes may be different, so lifetime annotations is needed, too.
#[derive(Debug)]
struct ImportantExcerpt<'a> { //An instance of ImportantExcerpt can’t outlive the reference it holds in its part field.
part: &'a str,
}
impl<'a> ImportantExcerpt<'a> {
fn announce_... | true |
9653a12368c0af5f66e6c5f69b86dfbe34e9a904 | Rust | fbegyn/podder | /src/episode.rs | UTF-8 | 2,910 | 3.203125 | 3 | [] | no_license | use reqwest::{header, Client};
use std::fmt;
use std::fs;
use std::path::Path;
#[derive(Clone)]
pub struct Episode {
title: String,
link: String,
url: String,
size: u64,
release_date: String,
downloaded: bool,
}
// Function that allows episodes to be printed
impl fmt::Display for Episode {
... | true |
9062da0504f54fc28d73bcf6be843f34c98923b0 | Rust | jcande/turnstyle_hopper | /src/path_state.rs | UTF-8 | 5,261 | 3.375 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::HashSet;
use crate::types::{Role, Passenger, VertexProperty};
use crate::cmd_tree::{CmdTree, CmdNode};
// XXX This should probably be an internal structure used by memory tree. A
// caller interacts solely with memory tree and calls "get_route". Memory tree
// repeatedly steps/unsteps unt... | true |
e4e23e02f21702515bb0e5089576f2be444290f9 | Rust | Scott-Olson/Morst | /src/main.rs | UTF-8 | 1,072 | 2.703125 | 3 | [] | no_license | #![feature(proc_macro_hygiene, decl_macro)]
use mors::{decoder, encoder};
use rocket::*;
#[get("/")]
fn index() -> String {
let encoder = encoder::Encoder::new();
let decoder = decoder::Decoder::new();
let s = String::from("morst").to_uppercase();
let result_encode = encoder.encode_letters(s);
le... | true |
6b9c13eb9c3e89ef0716d530970418cf75513c88 | Rust | sasurau4/lox-rust | /interpreter/src/lexer.rs | UTF-8 | 8,084 | 3.265625 | 3 | [] | no_license | use super::error::lexer_error;
use super::token::{Literal, Token};
use super::token_type::TokenType;
use std::collections::HashMap;
pub struct Lexer {
source: String,
tokens: Vec<Token>,
start: usize,
current: usize,
line: usize,
keywords: HashMap<String, TokenType>,
}
impl Lexer {
pub fn ... | true |
8329533e88624704e39e4c77d70a5443144a8248 | Rust | JeffreyRiggle/enigma-wasm | /enigmarust/enigmawasm/src/plugboard.rs | UTF-8 | 685 | 3.125 | 3 | [
"MIT"
] | permissive | pub struct Plugboard {
pub plugs: Vec<String>
}
impl Plugboard {
pub fn create(config: Vec<String>) -> Plugboard {
Plugboard {
plugs: config
}
}
pub fn shift(&mut self, letter: char) -> char {
let mut ret_val = letter;
for plug in self.plugs.iter() ... | true |
6073bf6c5140e1ec722ed73aa24122422bf1a9ce | Rust | dmolokanov/mqtt-storage | /src/main.rs | UTF-8 | 3,223 | 2.59375 | 3 | [
"MIT"
] | permissive | use std::{collections::BTreeMap, num::NonZeroU16};
use anyhow::Result;
use indicatif::{HumanBytes, ProgressBar, ProgressStyle};
use prettytable::{cell, row, Table};
use structopt::StructOpt;
use mqtt_storage::{
app::{self, EgressStats, IngressStats},
Memory, QueueFile, Sled,
};
#[tokio::main]
async fn main()... | true |
12515627b3c2d98595f4d8622d4e02d7203f1ef6 | Rust | kasumi8pon/atcoder_practice | /abc/abc253/src/bin/a.rs | UTF-8 | 256 | 2.96875 | 3 | [] | no_license | use proconio::input;
fn main() {
input! {
a: usize,
b: usize,
c: usize
}
let max = a.max(c);
let min = a.min(c);
if b >= min && b <= max {
println!("Yes");
} else {
println!("No");
}
}
| true |
4c32da550fad600e7a6cf770870f33809bc85ef3 | Rust | no111u3/ssd1320z2 | /src/buffered_graphics.rs | UTF-8 | 2,891 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | //! Buffered graphics mode.
use crate::{consts::ssd1320z2, error::Error, Ssd1320z2};
use core::convert::TryInto;
use display_interface::{DisplayError, WriteOnlyDataCommand};
use embedded_hal::{blocking::delay::DelayMs, digital::v2::OutputPin};
use embedded_graphics_core::{
pixelcolor::{Gray4, GrayColor},
pr... | true |
348be8787cd3370da1c3ea52481307df59e83e84 | Rust | trondhe/adventOfCode | /day_09_stream_processing/src/lib.rs | UTF-8 | 1,510 | 3.828125 | 4 | [] | no_license | pub fn process_stream(string: String) -> u32 {
let mut string_iterator = string.chars();
let mut sum = 0;
let mut level = 0;
let mut garbage_mode = false;
let mut contains = string_iterator.next();
while contains != None {
let c = contains.unwrap();
if c == '<' {
gar... | true |
d6b1e553e78f2ad2574480f72b0b98d96c67c257 | Rust | Bareflank/bsl | /include/bsl/assert.rs | UTF-8 | 3,103 | 2.90625 | 3 | [
"MIT"
] | permissive | // @copyright
// Copyright (C) 2020 Assured Information Security, Inc.
//
// @copyright
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation th... | true |
061d27ab71523c81370d0a5d6974decff85d52a7 | Rust | Fiedzia/rust-peg | /src/peg/codegen.rs | UTF-8 | 2,893 | 3.15625 | 3 | [
"MIT"
] | permissive | use std::cell::RefCell;
use std::io::Writer;
use std::cast::transmute_mut;
pub struct RustWriter {
writer: ~Writer,
indent: RefCell<uint>,
}
impl RustWriter {
pub fn new<W: Writer+Send>(writer: W) -> RustWriter {
RustWriter {
writer: ~writer as ~Writer,
indent: RefCell::new(0)
}
}
#[inline]
pub fn wr... | true |
9c6642939850fb1e208e871c0b766ea1069b175d | Rust | storycraft/emote-psb-rs | /src/types/string.rs | UTF-8 | 1,850 | 2.671875 | 3 | [
"MIT"
] | permissive | /*
* Created on Tue Jan 12 2021
*
* Copyright (c) storycraft. Licensed under the MIT Licence.
*/
use std::io::{Read, Write};
use crate::{PsbError, PsbErrorKind, PsbRefs};
#[cfg(feature = "serde")]
use serde::{Serialize, Deserialize};
use super::reference::PsbStringRef;
#[derive(Debug, PartialEq, Eq)]
#[cfg_att... | true |
8f60f4a4bff0792c067dcc07b96aaeec30a990c2 | Rust | ycrypto/rsa-cortex-m4 | /src/numbers/trait_implementations.rs | UTF-8 | 8,411 | 2.578125 | 3 | [] | no_license | use core::{cmp::Ordering, convert::TryFrom, fmt, ops::{Deref, DerefMut}};
use ref_cast::RefCast;
use super::{Array, Bits, Convenient, Digit, Number, NumberMut, Odd, Prime, Unsigned};
use crate::{Error, Result, Wrapping};
#[cfg(target_pointer_width = "32")]
impl Bits for usize {
const BITS: usize = 32;
}
#[cfg(... | true |
ce480a3d6cc11f270f6280fbc33bba14355dbf47 | Rust | whatalnk/cpsubmissions | /atcoder/rust/abc076/abc076_a/3573812.rs | UTF-8 | 568 | 2.640625 | 3 | [] | no_license | // Contest ID: abc076
// Problem ID: abc076_a ( https://atcoder.jp/contests/abc076/tasks/abc076_a )
// Title: A. Rating Goal
// Language: Rust (1.15.1)
// Submitted: 2018-11-10 06:32:09 +0000 UTC ( https://atcoder.jp/contests/abc076/submissions/3573812 )
use std::io;
fn gets() -> String {
let mut buf = String::n... | true |
04b50b41a1808128d52bcf4eb67f67df9543b451 | Rust | LaoQi/icode | /rust/closure/src/main.rs | UTF-8 | 372 | 3.75 | 4 | [] | no_license | fn factory() -> Box< Fn(i32) -> i32> {
let num = 5;
Box::new(move |x| x+num)
}
fn main() {
let f = factory();
let answer = f(1);
println!("factory {}", answer);
let v = 32;
let f = |x:i32| v + x;
let mut f2 = move|x:i32| v + x;
for i in 0..5{
let c = f(i);
let mut ... | true |
f3ceca6f4ca81d5e8f242835c914f6802a94d3b9 | Rust | kadude/simple_timer | /src/main.rs | UTF-8 | 2,497 | 3.09375 | 3 | [] | no_license | use notify_rust::{Notification, Timeout};
use std::env;
use std::io;
use std::io::prelude::*;
use std::thread::sleep;
use std::time::{Duration, Instant};
use chrono::{Local, NaiveTime};
fn time_left(time: u64, start: &Instant) -> u64 {
time - start.elapsed().as_secs()
}
fn format_duration(remaining_seconds: u64) ... | true |
45ffb7a8c533d16bf7470fab2f87a4dba0b321f5 | Rust | XuShaohua/nc | /src/calls/wait4.rs | UTF-8 | 1,090 | 3.28125 | 3 | [
"Apache-2.0"
] | permissive | /// Wait for process to change state.
///
/// # Example
///
/// ```
/// let ret = unsafe { nc::fork() };
/// match ret {
/// Err(errno) => {
/// eprintln!("fork() error: {}", nc::strerror(errno));
/// unsafe { nc::exit(1) };
/// }
/// Ok(0) => println!("[child] pid is: {}", unsafe { nc::getp... | true |
ecbaf4dcb1a00aafd9f6814f81e81106f9efca4e | Rust | JonasBak/imglang | /src/lexer.rs | UTF-8 | 8,142 | 3.546875 | 4 | [] | no_license | pub type LexerResult<T> = Result<T, LexerError>;
#[derive(Debug, PartialEq)]
pub enum LexerError {
Parse(usize),
Unescaped(usize),
}
#[derive(Debug, Clone, PartialEq)]
pub enum TokenType {
// Characters
LeftPar,
RightPar,
LeftBrace,
RightBrace,
LeftSquare,
RightSquare,
Comma,
... | true |
2b366c87c3b4302b885409339c6107931a26a0e9 | Rust | alvinmatias69/simple-2048 | /src/game/sound.rs | UTF-8 | 746 | 2.640625 | 3 | [] | no_license | use audio::SoundSource;
use ggez::{audio, Context, GameResult};
pub enum SoundType {
Start,
Win,
Lose,
Move,
UnableToMove,
Menu,
}
pub fn play(ctx: &mut Context, sound_type: SoundType) -> GameResult {
let path: String;
match sound_type {
SoundType::Start => path = String::from(... | true |
adaaa05771e8f19260c867c4b82e957f4da341fe | Rust | kliml/roguelike | /src/map.rs | UTF-8 | 8,688 | 2.71875 | 3 | [] | no_license | use rand::distributions::WeightedIndex;
use rand::prelude::*;
use std::cmp;
use tcod::colors::*;
use serde::{Deserialize, Serialize};
use crate::game::Game;
use crate::help::mut_two;
use crate::object::*;
use crate::settings::*;
use items::Item;
pub const MAP_WIDTH: i32 = 80;
pub const MAP_HEIGHT: i32 = 43;
pub co... | true |
c6858e2b6862b41bc4ca2b7d646120174c1602a5 | Rust | akheron/sala | /src/main.rs | UTF-8 | 5,133 | 2.953125 | 3 | [
"MIT"
] | permissive | use clap::{App, Arg, SubCommand};
use sala::{
config,
Error::{self, *},
Output::{self, *},
};
use std::env;
use std::ffi::OsString;
use std::path::{Path, PathBuf};
fn main() {
let app_m = App::new("sala")
.version("1.4")
.about("Store passwords and other sensitive information to plain t... | true |
88f8ccc79f18e09e87cd2df7f07fe145c0157ff7 | Rust | Azure/azure-sdk-for-rust | /services/autorust/codegen/examples/list_crates.rs | UTF-8 | 1,102 | 2.5625 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT",
"LGPL-2.1-or-later"
] | permissive | // cargo run --example list_crates
// This list all crates that are generated.
// cargo run --example list_crates -- 0.1.0
// If a version is passed in as an option, it will filter out any that
// are already published to crates.io.
// An updated clone of crates.io-index is required.
// git clone https://github.com/ru... | true |
d0995bbf2dcca846b7954a53ff8cf9d95c5292fe | Rust | isgasho/jlrs | /jlrs/src/memory/frame.rs | UTF-8 | 19,802 | 3.234375 | 3 | [
"MIT"
] | permissive | //! Frames protect values from garbage collection.
//!
//! Several kinds of frame exist in jlrs. The simplest one is [`NullFrame`], which is only used
//! when writing `ccall`able functions. It doesn't let you root any values or create a nested
//! scope, but can be used to (mutably) borrow array data. If you neither u... | true |
264333ed8dbb4b7128e0452fe6c51cbd67c27c40 | Rust | zzl133/my_rust_road | /learn-async/example-futures/src/main.rs | UTF-8 | 2,530 | 3.875 | 4 | [] | no_license | // `block_on` blocks the current thread until the provided future has run to
// completion. Other executors provide more complex behavior, like scheduling
// multiple futures onto the same thread.
use futures::executor::block_on;
use futures::join;
/// async/.await 是Rust内置的语法,用于让异步函数编写的像
/// 同步代码。async将代码块转化成实现了Future... | true |
9392e2a62a9eefbd00c5117ff5ed713748ee25c6 | Rust | arcnmx/nvapi-rs | /sys/src/gpu/pstate.rs | UTF-8 | 12,782 | 2.515625 | 3 | [
"MIT"
] | permissive | use crate::status::NvAPI_Status;
use crate::handles::NvPhysicalGpuHandle;
use crate::types::BoolU32;
use crate::gpu::clock;
pub const NVAPI_MAX_GPU_PSTATE20_PSTATES: usize = 16;
pub const NVAPI_MAX_GPU_PSTATE20_CLOCKS: usize = 8;
pub const NVAPI_MAX_GPU_PSTATE20_BASE_VOLTAGES: usize = 4;
nvstruct! {
pub struct NV... | true |
ecbb6e09d7d9178fd739dfe198843b94a3bcd3e2 | Rust | pablo-mansanet-bluefruit/efm32gg11b | /src/gpcrc.rs | UTF-8 | 7,684 | 2.515625 | 3 | [
"MIT"
] | permissive | #[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Control Register"]
pub ctrl: CTRL,
#[doc = "0x04 - Command Register"]
pub cmd: CMD,
#[doc = "0x08 - CRC Init Value"]
pub init: INIT,
#[doc = "0x0c - CRC Polynomial Value"]
pub poly: POLY,
#[doc = "0x10 -... | true |
3ae7f1834dba7e566fa7a3aecf53058159fecb96 | Rust | b4skyx/Algorithms-S60 | /longest-common-subsequence/src/main.rs | UTF-8 | 798 | 2.90625 | 3 | [] | no_license | use std::io;
fn lcs(a: Vec<char>, b: Vec<char>) {
let alen = a.len();
let blen = b.len();
let mut mem = vec![vec![-1; blen + 1]; alen + 1];
for i in 0..(alen as usize + 1) {
for j in 0..(blen as usize + 1) {
if i == 0 || j == 0 {
mem[i][j] = 0;
} else if ... | true |
2f0a56f30646b500da479cfb7d98fc6062144686 | Rust | solarsail/RagaMuffin | /src/render/renderer.rs | UTF-8 | 622 | 2.59375 | 3 | [] | no_license | use gfx;
#[derive(Debug)]
pub struct TextureRenderer {
pso: gfx::PipelineState,
ss: SpriteSheet,
}
impl TextureRenderer {
pub fn new(ss: SpriteSheet) -> Self {
let pso = factory
.create_pipeline_simple(
include_bytes!("shaders/simple_texture_150.glslv"),
... | true |
6504cc726493bf906e776c7dc54a5d5100de3bab | Rust | Hoyt-Systems-Texas/HoytSys.Rust_Common | /a19_core/src/pow2.rs | UTF-8 | 2,084 | 3.515625 | 4 | [] | no_license | pub trait PowOf2 {
fn round_to_power_of_two(&self) -> Self;
fn next_power_of_two(&self) -> Self;
fn is_power_of_2(&self) -> bool;
}
impl PowOf2 for u64 {
fn round_to_power_of_two(&self) -> u64 {
if self.is_power_of_2() {
*self
} else {
self.next_power_of_two()
... | true |
b61e725a73c5b86f1287d89e621b209f57a50e35 | Rust | benjaminch/advent-of-code | /2020/03/solution/src/main.rs | UTF-8 | 4,098 | 3.375 | 3 | [] | no_license | use std::io::{self, Error, ErrorKind, Read, Write};
use std::str::FromStr;
#[derive(PartialEq)]
enum Geology {
Tree,
Free,
Unknown,
}
impl FromStr for Geology {
type Err = Error;
fn from_str(input: &str) -> Result<Geology, Self::Err> {
match input {
"#" => Ok(Geology::Tree),
... | true |
11f3f8b22631876df74e92d8d75a2a37ef6ed424 | Rust | marmistrz/wasi-misc-tests | /src/bin/renumber.rs | UTF-8 | 3,254 | 2.734375 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | use libc;
use misc_tests::open_scratch_directory;
use misc_tests::utils::close_fd;
use misc_tests::wasi::{wasi_fd_close, wasi_fd_fdstat_get, wasi_fd_renumber, wasi_path_open};
use std::{env, mem, process};
fn test_renumber(dir_fd: libc::__wasi_fd_t) {
let pre_fd: libc::__wasi_fd_t = (libc::STDERR_FILENO + 1) as li... | true |
5bfe77ff6aec8e3c41155d968dc4950dda718e13 | Rust | mongodb/bson-rust | /src/document.rs | UTF-8 | 23,428 | 2.96875 | 3 | [
"MIT"
] | permissive | //! A BSON document represented as an associative HashMap with insertion ordering.
use std::{
error,
fmt::{self, Debug, Display, Formatter},
io::{Read, Write},
iter::{Extend, FromIterator, IntoIterator},
mem,
};
use ahash::RandomState;
use indexmap::IndexMap;
use serde::de::Error;
use crate::{
... | true |
896497690ce8f16f885ae95cf9c31285663fb75e | Rust | daxpedda/pliantdb | /core/src/schema/view.rs | UTF-8 | 3,966 | 3.09375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::borrow::Cow;
use serde::{Deserialize, Serialize};
use crate::document::Document;
/// Types for defining a `Map` within a `View`.
pub mod map;
pub use map::{Key, Map};
/// Errors that arise when interacting with views.
#[derive(thiserror::Error, Debug)]
pub enum Error {
/// An error occurred while seria... | true |
29ed6d3bc7f74eb2ae5b973fea5381adb047d8ae | Rust | Logicalshift/safas | /src/syntax/def.rs | UTF-8 | 6,274 | 3.203125 | 3 | [
"Apache-2.0"
] | permissive | use crate::bind::*;
use crate::exec::*;
use crate::meta::*;
use smallvec::*;
use std::sync::*;
use std::convert::*;
///
/// Creates the syntax definition for the 'def' keyword
///
/// ```(def <name> <value>)```
///
/// Assigns `<value>` to the atom called `<name>`. It is possible to redefine an existing atom. The v... | true |
54614e5d16a13bd578212976b2d9dbe1c9c974f7 | Rust | franza/share-me | /src/storage.rs | UTF-8 | 732 | 2.9375 | 3 | [] | no_license | use std::sync::Mutex;
use actix_web::rt::time::Instant;
#[derive(Debug, Clone)]
struct StoredLink {
value: String,
created_on: Instant,
}
#[derive(Debug)]
pub struct Storage {
links: Mutex<Vec<StoredLink>>
}
impl Storage {
pub fn new() -> Self {
Storage { links: Mutex::new(Vec::new()) }
}... | true |
6a3a9947dac0c46a32050d259ac6f829f7380d2a | Rust | lelandjansen/rust-playground | /book/functions/src/main.rs | UTF-8 | 433 | 3.375 | 3 | [] | no_license | //fn stuff(x: f64) {
// println!("{} is a float", x);
//}
fn stuff(x: i32) {
println!("{} is an i32", x);
}
fn main() {
println!("Hello, world!");
let x: i32 = 12;
stuff(x);
let x = {
let x = 7;
println!("ohai");
x * 3
};
println!("Here");
let y = x / 3;
... | true |
6751cf7d2b7d8beb2d08b6bd6a346401d97e9bcb | Rust | yaozijian/rust_net | /chap04/nom-http/src/main.rs | UTF-8 | 1,411 | 2.828125 | 3 | [] | no_license | #![feature(type_alias_enum_variants)]
use std::str;
use nom::{ErrorKind,IResult};
use nom::{named,return_error,alt,map_res,map};
use nom::{do_parse,tag,take_until,is_a};
#[derive(Debug)]
enum Method{
GET,
POST,
}
#[derive(Debug)]
struct Request{
method: Method,
url: String,
version: String,
}
na... | true |
0da16c5ed5bac19821ca334efcc917988a68abaa | Rust | Revertron/Blakeout | /src/lib.rs | UTF-8 | 4,173 | 3.4375 | 3 | [] | no_license | //! An implementation of the Blakeout hash function.
//!
//! # Usage
//!
//! `Blakeout` can be used in the following way:
//!
//! ```rust
//! use crypto::digest::Digest;
//! use blakeout::Blakeout;
//!
//! // create a Blakeout object, it will hash your bytes for you
//! let mut hasher = Blakeout::default();
//!
//! // ... | true |
6997cd555a8b935375dfeae4b22eacee49ff3e1a | Rust | ferruccio/llpr | /src/streams.rs | UTF-8 | 3,736 | 2.796875 | 3 | [
"MIT"
] | permissive | use crate::pdf_types::*;
use crate::PdfError;
use inflate::inflate_bytes_zlib;
struct Filter {
name: PdfName,
_decode_parms: Option<Dictionary>,
}
pub fn decode_stream(mut stream: Vec<u8>, stream_dict: Dictionary) -> crate::Result<Vec<u8>> {
let filters = filters(stream_dict)?;
for filter in filters.... | true |
39eb274acb9bb6b3e5501a038abef33bb73d9b4a | Rust | AlexandreImperiale/rody | /src/block.rs | UTF-8 | 7,624 | 3.53125 | 4 | [] | no_license | // Using base tools of mersh.
use mersh::base::*;
/// Data structure for defining blocks.
#[derive(Clone, Default, Debug)]
pub struct Block {
/// Total mass of the block.
pub mass: f64,
/// Associated length in each direction.
pub lengths: [f64; 3],
/// Associated position of the block center of ma... | true |
c27c5e5b8bef945d8084cc39abbb990cbe881615 | Rust | elicharlese/advent-of-code | /2018/src/bin/day01.rs | UTF-8 | 954 | 3.328125 | 3 | [] | no_license | use std::collections::HashSet;
use std::io::{self, Read};
type Result<T> = ::std::result::Result<T, Box<::std::error::Error>>;
fn main() -> Result<()> {
let input = parse_input()?;
part1(&input)?;
part2(&input)?;
Ok(())
}
fn parse_input() -> Result<Vec<i32>> {
let mut out = Vec::new();
let ... | true |
b928c1f57b7c678610265be899bf8d620a6c5bda | Rust | archer884/syncpath | /src/options.rs | UTF-8 | 1,702 | 3.25 | 3 | [] | no_license | use crate::sync;
use std::io;
use std::path::PathBuf;
/// Used to set program options.
///
/// For one-way operations, the `left` path represents the "from" path and the `right` path
/// represents the "to" path. For two-way operations, they are basically interchangeable.
///
/// The "sync-both" option represents a tw... | true |
8d47bb78ca8d52b9906b229bbc520720439939b3 | Rust | Celeo/matterterm | /src/config.rs | UTF-8 | 1,889 | 3.203125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! On-disk file configuration.
use crate::globals::CONFIG_FILE_NAME;
use anyhow::{anyhow, Result};
use serde::{Deserialize, Serialize};
use std::{
fs,
path::{Path, PathBuf},
};
/// Struct representing the on-disk program configuration.
#[derive(Debug, Default, Deserialize, Serialize)]
pub struct Config {
... | true |
e9ae51de9b70b03368e898336f8e2fa8e71fc4cc | Rust | museun/md2 | /src/triangle.rs | UTF-8 | 969 | 2.734375 | 3 | [
"Unlicense"
] | permissive | use {header::*, vertex::*, *};
#[derive(Debug)]
pub struct Triangle {
vertex: [Vertex; 3],
st: [short_t; 3],
}
#[derive(Debug)]
pub enum TriangleError {
MissingIndex,
VertexError(VertexError),
}
impl Triangle {
pub fn load<R>(rd: &mut R, hd: &Header) -> Result<Self, TriangleError>
where
... | true |
65778f935a87a1dc22200bbcded8e9e618491518 | Rust | PhilippGackstatter/ion | /src/parser.rs | UTF-8 | 35,136 | 3.15625 | 3 | [] | no_license | use crate::lexer::Lexer;
use crate::types::Token;
use crate::types::TokenKind::{self, *};
use crate::types::{
CompileError,
Declaration::{self, *},
Expression,
ExpressionKind::*,
Program,
Statement::{self, *},
};
use std::ops::Range;
type StatementResult = Result<Statement, CompileError>;
type ... | true |
13f5a908d2695be7b6f18730bdd367b2997e69e6 | Rust | Levertion/mcfunction-rs-1 | /crates/nbtdoc/src/syntax/testing.rs | UTF-8 | 3,482 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | // I might need some of these in the future when I decide
// to write parser unit tests
#![allow(dead_code)]
use super::{group::NdGroupType, lexer, tokens::NdTokenKind, NbtdocLang, NdParser};
use mcfunction_parse::{ast::AstView, parser::Parser, Ast, SyntaxKind, Token};
use std::fmt::Write;
pub fn format_astnode(node... | true |
def8d48d708435192e583608adb863cf99b8284b | Rust | edarc/max7301 | /src/expander/immediate.rs | UTF-8 | 3,425 | 3.21875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Immediate-mode I/O adapter.
use core::marker::PhantomData;
use expander::pin::{ExpanderIO, PortPin};
use expander::Expander;
use interface::ExpanderInterface;
use mutex::IOMutex;
use registers::valid_port;
/// This I/O adapter captures the `Expander` and provides a factory for generating GPIO pins that
/// imple... | true |
3f826fe47b92e87a45eb6fa84aa9d08ba2f5d418 | Rust | ahwatts/file-magic-rs | /src/magic/test.rs | UTF-8 | 5,415 | 3.109375 | 3 | [] | no_license | use crate::error::{MagicError, MagicResult};
use crate::data_type;
use num::{Num, Integer};
use std::fmt::Debug;
use std::mem;
use std::io::Read;
#[derive(Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)]
pub struct Test {
data_type: data_type::DataType,
test_type: TestType,
}
impl Test {
pub fn n... | true |
02ed59674a4b6af3491db274422abe97ba8cedf4 | Rust | karaketir16/rust-basic-grep | /src/main.rs | UTF-8 | 933 | 3.3125 | 3 | [] | no_license | use std::env;
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
fn main() {
let args: Vec<String> = env::args().collect();
finder(&args[1], (&args[2..]).to_vec());
}
fn finder(s: &String, filenames: Vec<String>) {
for filename in filenames.iter(){
if let Ok(lines) = read_line... | true |
221ab97b5ea08d250449d0bd15cdd17daef20d36 | Rust | ACRONYM-Group/ACIRustServer | /src/database/permissions.rs | UTF-8 | 9,095 | 3.234375 | 3 | [] | no_license | use log::{error, trace};
use serde_json::{Value, json};
/// Permission gating a value
#[derive(Debug, Clone)]
pub struct Permission
{
pub read_a_users: Vec<String>,
pub read_g_users: Vec<String>,
pub write_a_users: Vec<String>,
pub write_g_users: Vec<String>
}
impl Permission
{
/// Generate permi... | true |
a6d68726345480e9a8ee827d8f8cf6d6cc46dc10 | Rust | hygt/aoc2018 | /src/bin/day07b.rs | UTF-8 | 2,576 | 3.140625 | 3 | [
"Unlicense"
] | permissive | use std::collections::*;
use std::fs;
use std::str::FromStr;
#[derive(Debug, Eq, PartialEq)]
struct Vertex {
inc: BTreeSet<char>,
out: BTreeSet<char>,
}
fn main() {
// input content was edited for convenient parsing
let input = fs::read_to_string("resources/day07.txt").expect("Couldn't read file");
... | true |
74dfcac8e8ea496b356a2665f025f05167026426 | Rust | sueken5/resea | /servers/memmgr/initfs.rs | UTF-8 | 2,357 | 2.9375 | 3 | [
"MIT",
"CC0-1.0"
] | permissive | use resea::mem::size_of;
use resea::utils::c_str_to_str;
#[repr(C, packed)]
pub struct File {
/// The file path (null-terminated).
path: [u8; 48],
/// The size of files.
len: u32,
/// The size of the padding space immediately after the file content.
/// Padding will be added to align the beginn... | true |
ecf24664c9e958bb9c17a4adea8978b6c19c0ebf | Rust | Soya-Onishi/rust-riscv | /src/util/exception.rs | UTF-8 | 2,918 | 3.1875 | 3 | [] | no_license | #[allow(dead_code)]
#[derive(Debug, Clone, Copy)]
pub enum Exception {
UserSoftwareInterrupt,
SupervisorSoftwareInterrupt,
MachineSoftwareInterrupt,
UserTimerInterrupt,
SupervisorTimerInterrupt,
MachineTimerInterrupt,
UserExternalInterrupt,
SupervisorExternalInterrupt,
MachineExter... | true |
f1f5ab8bd8c8a5705252b6ee08bf965e3266fd6f | Rust | ELD/rusty-monkey | /src/eval/object.rs | UTF-8 | 4,131 | 3.109375 | 3 | [] | no_license | use crate::{
eval::environment::Environment,
parser::ast::{Block, Ident},
};
use nom::lib::std::{collections::HashMap, fmt};
use std::{
cell::RefCell,
fmt::{Debug, Display},
hash::{Hash, Hasher},
rc::Rc,
};
type Builtin = fn(Vec<Object>) -> Object;
#[derive(Clone, Eq)]
pub enum Object {
In... | true |
20857f63b54e2354f7c1ad98145165495589501d | Rust | huxy11/aliyun_oss_rust_sdk | /src/types/options/get_object.rs | UTF-8 | 4,222 | 2.953125 | 3 | [
"MIT"
] | permissive | use headers_serializer::ToMaps;
#[derive(Clone, Debug, Default, PartialEq, ToMaps)]
// #[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct GetObjectOptions {
/// <p>The content-type header in the response that OSS returns.</p>
#[label("opts")]
pub response_content_type: Option<Stri... | true |
0ff15173879d8fb508e9c2bf575bb45066c0822f | Rust | ajmwagar/batterup | /src/main.rs | UTF-8 | 1,923 | 2.9375 | 3 | [] | no_license | #[macro_use]
extern crate chan;
extern crate notify_rust;
use notify_rust::Notification;
fn main() {
// Run once
batterup();
// Setup recuring timer
let timer = chan::tick_ms(60000);
loop {
chan_select! {
timer.recv() => batterup(),
}
}
}
fn batterup(){
use st... | true |
1e434d3b56bbab98b2c14ecf9744fb39e11d0be4 | Rust | UniteIdeas/exonum | /exonum/src/crypto.rs | UTF-8 | 22,703 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2017 The Exonum Team
//
// 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 agreed to i... | true |
636c1590e8f40c42d5e3eb0a85a25e51fb8f4d80 | Rust | sahwar/broot | /src/conf.rs | UTF-8 | 6,865 | 3.125 | 3 | [
"MIT"
] | permissive | //! manage reading the verb shortcuts from the configuration file,
//! initializing if if it doesn't yet exist
use directories::ProjectDirs;
use std::collections::HashMap;
use std::fs;
use std::io;
use std::path::{Path, PathBuf};
use std::result::Result;
use toml::{self, Value};
use crate::skin_conf;
use crate::error... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.