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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
521eefb52c78363931260e35a56b20ebbac5a7e9 | Rust | erikmannerfelt/manus | /src/io.rs | UTF-8 | 6,164 | 3.359375 | 3 | [
"MIT"
] | permissive | use serde_json::Value as Json;
use std::fs::File;
use std::io::prelude::*;
use std::path::{Path, PathBuf};
/// Try to parse and return a filepath.
///
/// # Arguments
/// - `filepath_str`: A relative or absolute filepath string.
/// - `expected_extension`: Optional. The expected extension. An extension-less path will ... | true |
8409c7051abe917d7c3446cf543c369f15dd656e | Rust | arruw/aoc-2020 | /src/day_07.rs | UTF-8 | 4,945 | 3.1875 | 3 | [] | no_license | use itertools::Itertools;
use std::collections::*;
const DAY: u32 = 7;
type Input = HashMap<String, HashMap<String, usize>>;
type Output = usize;
fn input_transformer(input: &str) -> Input {
input
.lines()
.map(|l| {
l.replace("bags", "")
.replace("bag", "")
... | true |
01a639b6b8fabe206403f23a4b54eefea7f2086d | Rust | gugi9000/Gust | /src/backend/elements/general.rs | UTF-8 | 4,196 | 3.703125 | 4 | [] | no_license |
use std::collections::HashMap;
use serde::ser::{Serialize, Serializer, SerializeStruct};
/// Orientation is an enum for the different possible axis values
#[derive(Serialize)]
#[serde(rename_all = "lowercase")]
pub enum Orientation {
Top,
Left,
Bottom,
Right,
}
/// A small helper struct that represe... | true |
61cbef962d9bdab8c2c769084918a5e1d27c35f4 | Rust | Restioson/freqs | /src/main.rs | UTF-8 | 1,264 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | use std::cmp::Reverse;
use std::collections::HashMap;
use std::{env, fs};
use std::fs::File;
use std::io::BufWriter;
use csv::Writer;
use itertools::Itertools;
fn main() {
let dir = fs::read_dir(env::args().nth(1).expect("Pass the directory by the command line")).unwrap();
let needles = env::args().skip(2);
... | true |
38184a97d36bb29fcc865d5a2efd84c576a8061f | Rust | bpa/advent-of-code | /2021/src/day5.rs | UTF-8 | 1,746 | 2.921875 | 3 | [] | no_license | use std::cmp::Ordering;
#[aoc(day5, part1)]
fn d5part1(input: &str) -> isize {
let vectors = input
.lines()
.map(|l| l.split(" -> "))
.map(|mut l| {
let a = l.next().unwrap();
let b = l.next().unwrap();
let mut one = a.split(',');
let x = one.... | true |
68360b0d2ef0c53fd753c607a7825e1e6af677dc | Rust | avitex/rust-dnscat | /dnscat/src/util/parse.rs | UTF-8 | 1,751 | 2.8125 | 3 | [
"MIT"
] | permissive | use std::mem::size_of;
use std::str::Utf8Error;
use bytes::{Buf, Bytes};
use failure::Fail;
use generic_array::{ArrayLength, GenericArray};
use crate::util::StringBytes;
#[derive(Debug, Clone, PartialEq, Fail)]
#[fail(display = "Needed length {}", _0)]
pub struct Needed(pub usize);
#[derive(Debug, Clone, PartialEq)... | true |
6b4ef4654b93d1cb6fdbb764ec53094b037bcc17 | Rust | neont21/pjos-rust-programming | /chapter08/practice/company/src/main.rs | UTF-8 | 3,275 | 3.46875 | 3 | [
"Apache-2.0"
] | permissive | use std::io;
use std::collections::HashMap;
fn main() {
let mut company: HashMap<String, Vec<String>> = HashMap::new();
println!("**************************************************************************");
println!("* Type \"Add {{employee}} to {{department}}\" to insert *");
... | true |
cb3da432b0cf38d73b1dd8883583bd13c013bff0 | Rust | sile/trackable | /examples/your_own_error_type_template.rs | UTF-8 | 737 | 2.796875 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate trackable;
use trackable::error::{ErrorKind as TrackableErrorKind, ErrorKindExt};
use trackable::error::{Failure, TrackableError};
#[derive(Debug, Clone, TrackableError)]
pub struct Error(TrackableError<ErrorKind>);
impl From<Failure> for Error {
fn from(f: Failure) -> Self {
Err... | true |
967eaf818db3c3eb89894ba5b14a5a7cafbae23e | Rust | mvanbem/sudoku-generator | /src/sudoku.rs | UTF-8 | 4,091 | 3.34375 | 3 | [] | no_license | #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub enum VariableKind {
Placed {
row: Row,
col: Col,
digit: Digit,
},
Given {
row: Row,
col: Col,
},
Forced {
row: Row,
col: Col,
digit: Digit,
level: usize,
... | true |
7f445122d0c13cff78fda1b061b1985fa3a29d96 | Rust | Josh7GAS/Oficina | /Rust/CLI_tool_practice/grrs_StructOpt/src/main.rs | UTF-8 | 681 | 3.40625 | 3 | [] | no_license | use structopt::StructOpt;
//now we will parse the arguments with StructOpt, a library to parsing commands is clap.
//clap suports sub-comands, shell completions, and help messages
//using structopt
#[derive(StructOpt)]
struct Cli{
//the pattern to look for
pattern: String,
//the path to the file to read
... | true |
333b1f45556cc8ec8602f69b7350e2da416c9534 | Rust | brson/muddy | /src/mdy_ump/types.rs | UTF-8 | 2,443 | 3.140625 | 3 | [] | no_license | use anyhow::{Result, Error, bail};
use std::convert::{TryInto, TryFrom};
use num_enum::TryFromPrimitive;
const NIBBLE_MASK: u32 = 0xF;
//+ M2-104-UM 2.1 UMP Basic Packet and Message Format
pub struct Packet {
/// Native-endian words
data: [u32; 4],
}
//+ M2-104-UM 2.1.2 UMP Format Universal Fields
impl ... | true |
bac2e32877d50cc4b7d231e114904901c9d9d02a | Rust | waywardmonkeys/limn | /examples/util/mod.rs | UTF-8 | 1,239 | 2.8125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | extern crate glutin;
extern crate env_logger;
use limn::window::Window;
use limn::app::App;
use limn::input::{EscKeyCloseHandler, DebugSettingsHandler};
use limn::geometry::Size;
/// Create the window and initialize the app.
/// The window size is initialized to 100x100 and then resized later based
/// on the measure... | true |
e5e5b4984f3fc1e885530540d58b28262e417919 | Rust | davedufresne/modern_snmp | /src/snmp_usm/src/priv_key/aes128_priv_key.rs | UTF-8 | 2,531 | 2.734375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use super::{PrivKey, PRIV_KEY_LEN};
use crate::{LocalizedKey, SecurityError, SecurityParams, SecurityResult, WithLocalizedKey};
use aes::cipher::{AsyncStreamCipher, IvSizeUser, KeyIvInit};
use aes::Aes128;
use cfb_mode::{Decryptor, Encryptor};
type Aes128CfbEnc = Encryptor<Aes128>;
type Aes128CfbDec = Decryptor<Aes128... | true |
db85baa88f83f8e796a16c9194ec09911603d5c1 | Rust | ericcanton/cwl | /src/logs.rs | UTF-8 | 7,807 | 2.9375 | 3 | [
"MIT"
] | permissive | use std::fmt;
use std::rc::Rc;
use colored::*;
use chrono::Utc;
use rusoto_core::Region;
use rusoto_logs::{
CloudWatchLogs, CloudWatchLogsClient, DescribeLogGroupsRequest, DescribeLogGroupsResponse,
DescribeLogStreamsRequest, LogGroup as rusoto_LogGroup, LogStream as rusoto_LogStream,
OutputLogEvent, Get... | true |
d786f8856f73192f4281193e14d3077d1172f431 | Rust | nezdolik/ptscan | /lib/src/values.rs | UTF-8 | 13,636 | 3.171875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Optimized storage for in-memory values.
use crate::{Type, Value};
use byteorder::{ByteOrder, NativeEndian};
use std::{fmt, iter};
const MASK: u64 = 0x00_ff_ff_ff_ff_ff_ff_ffu64;
// Helper macro to decode a simple value.
macro_rules! decode_value {
($type:expr, $buf:expr) => {
decode_value!(@inner $ty... | true |
69c716ec18f077f8882172c2cbc3e47bdb91c544 | Rust | piccell/cheapshop | /src/views/main.rs | UTF-8 | 2,382 | 2.515625 | 3 | [] | no_license | use crate::models::item_name::ItemName;
use maud::{html, Markup, DOCTYPE};
fn header() -> Markup {
html! {
(DOCTYPE)
head {
meta charset="utf-8";
link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css";
link href="https://fonts.googleapis.com/icon?fam... | true |
2185bf8af2279d360fff64d14611acf27ee72739 | Rust | fruit-in/exercism-solution | /rust/nucleotide-count/src/lib.rs | UTF-8 | 649 | 3.203125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
pub fn count(nucleotide: char, dna: &str) -> Result<usize, char> {
match nucleotide {
'A' | 'C' | 'G' | 'T' => match dna.chars().find(|&ch| !"ACGT".contains(ch)) {
Some(e) => Err(e),
None => Ok(dna.chars().filter(|&ch| ch == nucleotide).count()),
... | true |
a7392b27ac1ed1e71975797c248d81dec58db603 | Rust | raffalevy/math_parser | /src/eval.rs | UTF-8 | 7,690 | 3 | 3 | [] | no_license | use std::collections::HashMap;
use parser::MathParseError;
use visitor::Visitor;
use ast;
use std::f64;
pub type EvalResult = Result<Option<f64>, MathParseError>;
pub struct EvalContext {
stack: Vec<StackFrame>,
}
#[derive(Debug)]
pub struct StackFrame {
vars: HashMap<String, f64>,
funcs: HashMap<String... | true |
046c90addaba324e99b4b1257f236871eef211ae | Rust | internetimagery/screeps-starter-rust | /src/prelude.rs | UTF-8 | 2,041 | 2.734375 | 3 | [
"MIT"
] | permissive | // General utilities
use screeps::objects::Attackable;
use screeps::objects::{Creep, Source, Structure};
use screeps::{find, prelude::*, ResourceType};
pub trait StoreUtility: HasStore {
// Return true if unit is full
fn is_full(&self, res: ResourceType) -> bool {
self.store_free_capacity(Some(res)) =... | true |
9cdfb0c86cebb6b025d154b769c183beb9bd7815 | Rust | JakubesP/flocking-alg-with-custom-shader-usage | /src/flocking.rs | UTF-8 | 9,845 | 2.546875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::default::Default;
use swgl::camera2d::interface::CameraType;
use swgl::gl_wrapper::vertex_array_object::PrimitiveType;
use swgl::global_tools::helpers::random_numbers::get_random;
use swgl::global_tools::vector2::Vector2;
use swgl::graphics_2d::color::Color;
use swgl::graphics_2d::renderer::geometry_renderer:... | true |
ed9511d6dea1bae815ba95d2fee15175b692bf12 | Rust | techhazard/teensy-firmware | /src/watchdog.rs | UTF-8 | 1,196 | 2.671875 | 3 | [] | no_license | use core::arch::arm::__NOP;
#[repr(C,packed)]
pub struct Watchdog {
/// Status and Control Register High
stctrlh: u16,
/// Status and Control Register Low
stctrll: u16,
/// Time-out Value Register High
tovalh: u16,
/// Time-out Value Register Low
tovall: u16,
/// Window Register Hi... | true |
da42c6158e3d59c1c45941019fe152e1ab353dbc | Rust | dayang/leetcode-rs | /maximum-subarray/src/main.rs | UTF-8 | 1,113 | 3.8125 | 4 | [] | no_license | //! ## 最大子序和 ##
//! [原题目地址](https://leetcode-cn.com/problems/maximum-subarray/) 难度:<b>简单</b>
//! ### 题目描述 ###
//! 给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。
//!
//! 示例:
//!
//! 输入: [-2,1,-3,4,-1,2,1,-5,4],
//! 输出: 6
//! 解释: 连续子数组 [4,-1,2,1] 的和最大,为 6。
pub struct Solution;
impl Solution {
/// 贪心思想,只有当子序... | true |
84e8cf05b4a372c78aa3cda773bb10c65218e5b9 | Rust | danleechina/Leetcode | /Rust_Sol/src/archive0/s345.rs | UTF-8 | 1,173 | 3.234375 | 3 | [] | no_license | impl Solution {
pub fn reverse_vowels(s: String) -> String {
if s.len() == 0 {
return "".to_owned();
}
unsafe {
let mut ss = s.clone();
let mut s = ss.as_bytes_mut();
let mut start: usize = 0;
let mut end = s.len() - 1;
while start < end {
... | true |
415cdb6a7fb5f7b6ed3eeebd6523ca72a61e6b8e | Rust | GaloisInc/mir-verifier | /lib/libterm/terminfo/mod.rs | UTF-8 | 7,498 | 2.921875 | 3 | [] | permissive | //! Terminfo database interface.
use std::collections::HashMap;
use std::env;
use std::error;
use std::fmt;
use std::fs::File;
use std::io::{self, prelude::*, BufReader};
use std::path::Path;
use crate::color;
use crate::Attr;
use crate::Terminal;
use parm::{expand, Param, Variables};
use parser::compiled::{msys_ter... | true |
3095b32ecb1b09e976504eb7754bf3792aed97c2 | Rust | sailfish009/rust_os | /src/time/mod.rs | UTF-8 | 2,353 | 2.953125 | 3 | [
"MIT"
] | permissive | use core::cmp::Ordering;
use spin::Mutex;
use pit::TIME_BETWEEN_E_12;
#[derive(Copy, Clone)]
pub struct SystemClock {
seconds: u64,
nano_fraction: u64
}
impl SystemClock {
pub const fn new() -> SystemClock {
SystemClock {seconds: 0, nano_fraction: 0}
}
pub fn tick(&mut self) {
use... | true |
59426bbb23da39ba01996df14af581883e0fc2e2 | Rust | Fien-Dora/p1-25-coding-challenges-ds | /kanye/src/part1/exercise8.rs | UTF-8 | 283 | 3.640625 | 4 | [] | no_license | // function to display output of to_fahreheit
pub fn display_fahr(cel: i32) {
println!("{}", to_fahrenheit(cel));
}
// function to convert input from celcius to fahrenheit
pub fn to_fahrenheit(celcius: i32) -> i32 {
let fahrenheit = celcius * 9 / 5 + 32;
fahrenheit
}
| true |
9e18c85309431d89af4efd65b61fb0846b044b17 | Rust | GuildOfWeavers/winterfell | /examples/src/fibonacci/mulfib2/air.rs | UTF-8 | 3,126 | 2.625 | 3 | [
"MIT"
] | permissive | // Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
use crate::utils::are_equal;
use winterfell::{
math::{fields::f128::BaseElement, FieldElement},
Air, AirContext, Assertion, Evalua... | true |
9e620a8ea7487a625db913250312e975661904bb | Rust | equalsraf/ffcli | /marionette/src/messages.rs | UTF-8 | 11,164 | 3 | 3 | [] | no_license | //! Structures for some of the messages used in the Marionette protocol, these can
//! be used with the traits in serde to convert into the corresponding json.
//!
#![allow(non_snake_case)]
use std::fmt;
use std::path::Path;
use std::collections::HashMap;
use serde::{Serialize, Serializer, Deserialize, Deserializer};
... | true |
4e735115665fe8b78c1d0b59566e4b0d78da5ddf | Rust | will-weiss/Fanta | /src/processed_route.rs | UTF-8 | 801 | 3.421875 | 3 | [] | no_license | pub struct ProcessedRoute {
pub head: String,
pub tail: Option<String>
}
pub fn process_route(route: String) -> Option<ProcessedRoute> {
if route.len() == 0 {
return None
}
let mut split = route.split("/");
match split.next() {
Some(head) => {
match split.next() {
Some(tail) => {
... | true |
1edb1c61d7e8d96a69b0a94a0955ef742e5266e0 | Rust | Kixiron/crunch-lang | /crates/crunch-typecheck/build.rs | UTF-8 | 1,652 | 2.90625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::{
env,
error::Error,
fs::{self, DirEntry},
io,
path::Path,
process::Command,
};
fn main() -> Result<(), Box<dyn Error>> {
// Traverse ddlog/ and rerun the DDlog build if any files have changed
traverse("ddlog", &|entry| {
let path = entry.path();
if matches!(
... | true |
d273b7998343ec1df66791b634da933d14226b0d | Rust | taiki-e/polonius | /polonius-parser/src/ir.rs | UTF-8 | 2,506 | 3.328125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! test input data model
#[derive(Debug)]
pub struct Input {
pub placeholders: Vec<Placeholder>,
pub known_subsets: Vec<KnownSubset>,
pub blocks: Vec<Block>,
pub use_of_var_derefs_origin: Vec<(String, String)>,
pub drop_of_var_derefs_origin: Vec<(String, String)>,
}
impl Input {
pub fn new(
... | true |
c0803175735edf8f0df075a9ad0ee722ed96f65e | Rust | peter-signal/dtls | /src/change_cipher_spec/change_cipher_spec_test.rs | UTF-8 | 923 | 2.578125 | 3 | [
"MIT"
] | permissive | use super::*;
use std::io::{BufReader, BufWriter};
use util::Error;
#[test]
fn test_change_cipher_spec_round_trip() -> Result<(), Error> {
let c = ChangeCipherSpec {};
let mut raw = vec![];
{
let mut writer = BufWriter::<&mut Vec<u8>>::new(raw.as_mut());
c.marshal(&mut writer)?;
}
... | true |
12350fc4897a9fca87212e863478408b3ee4be30 | Rust | 10allday-kai/api-daemon | /third-party/tinyfiledialogs/src/lib.rs | UTF-8 | 8,819 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | extern crate libc;
use libc::{c_char, c_uchar, c_int};
use std::ffi::{CStr, CString};
use std::ptr;
extern {
fn tinyfd_messageBox (
aTitle: *const c_char ,
aMessage: *const c_char,
aDialogType: *const c_char,
aIconType: *const c_char,
aDefaultButton: c_int) -> c_int;
fn... | true |
f56d33be058a2f84aeb76f62d7a2c9a7df8dd035 | Rust | cvybhu/sasinc | /src/sasinc/money_pool.rs | UTF-8 | 2,527 | 2.8125 | 3 | [] | no_license | use crate::money::Money;
use std::cell::{Cell, RefCell};
use std::collections::VecDeque;
use std::future::Future;
use std::pin::Pin;
use std::rc::Rc;
use std::task::{Context, Poll, Waker};
pub struct MoneyPool {
money: Cell<Money>,
take_requests: RefCell<VecDeque<Rc<RefCell<MoneyTakeRequest>>>>,
}
impl MoneyP... | true |
eda231966e947f41b0a95cf7a1b641c67a5aabb4 | Rust | actix/actix-web | /actix-web/src/lib.rs | UTF-8 | 4,505 | 2.59375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.
//!
//! # Examples
//! ```no_run
//! use actix_web::{get, web, App, HttpServer, Responder};
//!
//! #[get("/hello/{name}")]
//! async fn greet(name: web::Path<String>) -> impl Responder {
//! format!("Hello {}!", name)
//! }
//!
//! ... | true |
aa929f553cff3004bd99dc0430f527bb0adc30c7 | Rust | CarloMicieli/railists-rs | /src/data_source/yaml_collections.rs | UTF-8 | 3,294 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | use chrono::{NaiveDate, NaiveDateTime};
use super::yaml_rolling_stocks::YamlRollingStock;
use crate::domain::{
catalog::{
brands::Brand,
catalog_items::{CatalogItem, DeliveryDate, ItemNumber, PowerMethod},
rolling_stocks::RollingStock,
scales::Scale,
},
collecting::{
... | true |
020c96c611bc66e7c1c8cb2be150e3fb96ce7322 | Rust | VictorKoenders/email_client | /client/src/ui/email_list.rs | UTF-8 | 2,421 | 2.953125 | 3 | [] | no_license | use shared::email::{Email, EmailHeader};
use std::rc::Rc;
use yew::prelude::*;
pub enum Msg {
EmailClicked(usize),
}
pub struct EmailList {
pub emails: Vec<Rc<EmailHeader>>,
pub email_selected: Option<Callback<usize>>,
pub current: Option<Rc<Email>>,
}
#[derive(Default, Clone, PartialEq)]
pub struct ... | true |
b9166d2bdbee856bb429ad6fe49a8b3b66e7349a | Rust | crazymykl/r7-rs | /src/lisp_value/primitive_function.rs | UTF-8 | 1,906 | 3.078125 | 3 | [] | no_license | use lisp_value::{LispValue, LispResult};
use lisp_environment::LispEnvironment;
use std::rc::Rc;
use std::fmt;
pub type LispPrimitiveFunction = Rc<Fn(&[LispValue]) -> LispResult>;
#[derive(Clone)]
pub struct PrimitiveFunction {
name: String,
args: Vec<String>,
varargs: Option<String>,
func: LispPrimit... | true |
56a2a7641217302e4a1df8f324c550b0da3a9088 | Rust | yamash723/pixelast | /src/lib.rs | UTF-8 | 8,071 | 2.640625 | 3 | [
"MIT"
] | permissive | #![doc(html_root_url = "https://docs.rs/pixelast/0.1.0")]
//! This library is Pixela client for Rust.
//!
//! # Example
//!
//! ```rust,ignore
//! use pixelast::{PixelaClient, ConsentAnswer, GraphType, GraphColor};
//!
//! fn main() {
//! let res = PixelaClient::create_new_user(
//! "username",
//! ... | true |
8d576a83c92a26b0986537699519ba51f4b34ac1 | Rust | ladycarbonfiber/AdventOfCode | /src/day10.rs | UTF-8 | 1,799 | 3.15625 | 3 | [] | no_license | use common::read_input;
use common::Part;
pub fn solve(part:Part){
let input = read_input(10);
let lengths:Vec<usize> = match part{
Part::PartOne =>{
input.split(",").map(|s| s.parse().unwrap()).collect()
},
Part::PartTwo=>{
let standard_lengths:Vec<usize> = vec!... | true |
ce42799c8e646cecd4932d9e5f2e5661f39a6027 | Rust | Hanaasagi/kurumi | /device/src/tty.rs | UTF-8 | 1,197 | 2.796875 | 3 | [
"MIT"
] | permissive | // tty is a device used to user's input & output
// input come form keyboard
// output to screen via vga.c
extern crate spin;
extern crate vga;
use spin::Mutex;
const NTTY_BUF: u32 = 512;
#[allow(non_camel_case_types)]
pub struct TTY_Buf {
nread: u32,
nwrite: u32,
buf: [char; NTTY_BUF as usize],
}
... | true |
04f1ae67f7b44075634b69083e3ea2c612f551ae | Rust | bookinstock/rswap | /src/main.rs | UTF-8 | 456 | 2.75 | 3 | [] | no_license | use std::env;
// use std::io;
use std::fs;
fn main() -> std::io::Result<()> {
let args: Vec<String> = env::args().collect();
println!("{:?}", args);
let file_name_1 = &args[1];
let file_name_2 = &args[2];
let file_name_tmp = &format!("{}_tmp", file_name_1)[..];
fs::rename(file_name_1, file_na... | true |
83f779506f6930717c0eaa179c87f02728ad775b | Rust | rrokkam/bf | /src/main.rs | UTF-8 | 2,658 | 3.390625 | 3 | [] | no_license | struct Program {
data: Vec<u8>,
data_pointer: usize,
instructions: Vec<u8>,
instruction_pointer: usize,
}
impl Program {
pub fn new(program: Vec<u8>) -> Self {
Program {
data: vec![0; 30_000],
data_pointer: 0,
instructions: program,
instructio... | true |
298e42aec3711f5589c109540072e4f0a19e2dfa | Rust | WarrenWeckesser/experiments | /rust/rand_demos/normal_demo/src/main.rs | UTF-8 | 1,195 | 3.0625 | 3 | [] | no_license | use rand_distr::{Distribution, Normal};
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(
name = "normal_demo",
about = "Generate samples from the normal distribution"
)]
struct Opt {
/// Mean
#[structopt(short = "m", long = "mu", default_value = "0")]
mu: f64,
/// Standard de... | true |
04bdb81ea30d835f4f23d6c5d72d6c322feca7b4 | Rust | elauffenburger/rs-proto | /src/parser/mod.rs | UTF-8 | 20,349 | 2.921875 | 3 | [] | no_license | pub mod types;
use pest::iterators::{Pair, Pairs};
use pest::Parser as PestParser;
pub use types::*;
#[derive(Parser)]
#[grammar = "../grammars/proto.pest"]
struct PestProtoParser;
pub trait Parser {
fn parse<'a>(&self, input: &'a str) -> Result<Program<'a>, String>;
}
pub fn new_parser() -> impl Parser {
P... | true |
f8954ed82e78b37cd5a1ba41d09ca7b37bd9fac7 | Rust | 0queue/rust-ctree | /src/ctree.rs | UTF-8 | 1,401 | 3.140625 | 3 | [] | no_license | use rand;
use rand::Rng;
pub struct CTree {
pub branches: Vec<Branch>,
pub max_width: usize,
}
pub struct Branch {
pub width: usize,
pub ornaments: Vec<usize>,
}
pub const MIN_HEIGHT: usize = 8;
impl CTree {
pub fn new(height: usize) -> CTree {
let h = if height > MIN_HEIGHT { height }... | true |
9057ce040f727feea0aac5b397ccc249c127db70 | Rust | klvnptr/rayt | /src/scenes/cornell_box.rs | UTF-8 | 2,635 | 2.71875 | 3 | [
"MIT"
] | permissive | use crate::camera::{CameraSave, Lens};
use crate::config::ConfigSave;
use crate::data::colour::Colour;
use crate::data::vector::Vector;
use crate::world::background::Background;
use crate::world::geometry::cube::Cube;
use crate::world::geometry::rectangle::{XyRect, XzRect, YzRect};
use crate::world::geometry::Geometry;... | true |
787544f2f93794aaa30482c30c1030ea07a4ea79 | Rust | reschke/routinator | /src/output.rs | UTF-8 | 19,475 | 2.796875 | 3 | [
"BSD-3-Clause"
] | permissive | //! Output of lists of VRPs.
// Some functions here have unnecessarily wrapped return types for
// consisitency.
#![allow(clippy::unnecessary_wraps)]
use std::io;
use std::str::FromStr;
use chrono::Utc;
use chrono::format::{Item, Numeric, Pad};
use log::error;
use rpki::repository::resources::AsId;
use crate::metrics... | true |
c66666ea10d41a5502cc8b980d5f9b119cf2375c | Rust | chops76/AoC2020 | /src/day1.rs | UTF-8 | 1,265 | 3.21875 | 3 | [] | no_license | use itertools::Itertools;
use std::io::{BufRead, BufReader};
use std::fs::File;
use std::time::Instant;
type Input = Vec<u32>;
fn parse_input() -> Input {
let path = "./input/day1/input1.txt";
let f = File::open(path).unwrap();
BufReader::new(f).lines().flatten().map(|s| s.parse().unwrap()).collect()
}
f... | true |
9dc2449e1effae9622fce6d21db34daf4b76b538 | Rust | zhiburt/tabled | /tabled/tests/settings/width_test.rs | UTF-8 | 89,941 | 2.5625 | 3 | [
"MIT"
] | permissive | #![cfg(feature = "std")]
use tabled::{
grid::util::string::string_width_multiline,
settings::{
formatting::{TabSize, TrimStrategy},
object::{Columns, Object, Rows, Segment},
peaker::{PriorityMax, PriorityMin},
width::{Justify, MinWidth, SuffixLimit, Width},
Alignment, Ma... | true |
39360303b67277b1f9a848f506bfe48a1af1d096 | Rust | 5l1v3r1/kerla | /kernel/fs/initramfs.rs | UTF-8 | 9,785 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | //! Initramfs parser.
//! <https://www.kernel.org/doc/html/latest/driver-api/early-userspace/buffer-format.html>
use crate::{
fs::{
file_system::FileSystem,
inode::{DirEntry, Directory, FileLike, FileType, INode, INodeNo},
path::Path,
stat::FileMode,
stat::{Stat, S_IFDIR},
... | true |
725193f9632d8387d04e79fde56a35f8877c5ef5 | Rust | mdm/adventofcode2020 | /day06/src/main.rs | UTF-8 | 1,243 | 3.21875 | 3 | [] | no_license | use std::{io::BufRead};
use std::collections::HashSet;
fn main() {
let filename = std::env::args().nth(1).unwrap();
let file = std::fs::File::open(filename).unwrap();
let reader = std::io::BufReader::new(file);
let all_chars: HashSet<_> = "abcdefghijklmnopqrstuvwxyz".chars().collect();
let mut gr... | true |
1076a1f1006b6011d44b30f8c1c4e3258893a850 | Rust | gbutler69/rust-exercism | /all-your-base/src/lib.rs | UTF-8 | 2,640 | 3.703125 | 4 | [] | no_license | #[derive(Debug, PartialEq)]
pub enum Error {
InvalidInputBase,
InvalidOutputBase,
InvalidDigit(u32),
}
///
/// Convert a number between two bases.
///
/// A number is any slice of digits.
/// A digit is any unsigned integer (e.g. u8, u16, u32, u64, or usize).
/// Bases are specified as unsigned integers.
/... | true |
7f75d7b3d221b76e944aa63fe6dec77398bf14fe | Rust | alshamiri5/rust-readme-client | /src/error.rs | UTF-8 | 513 | 2.640625 | 3 | [
"MIT"
] | permissive | use std;
use reqwest;
#[derive(Debug)]
pub enum Error {
Io(std::io::Error),
Reqwest(reqwest::Error),
Response(reqwest::Response),
}
impl From<std::io::Error> for Error {
fn from(error: std::io::Error) -> Self {
Error::Io(error)
}
}
impl From<reqwest::Error> for Error {
fn from(error: ... | true |
4a3343d9a61e09189851bcaf02062790ae58d955 | Rust | kiwiscott/advent-of-code | /8/src/main.rs | UTF-8 | 1,791 | 3.46875 | 3 | [] | no_license | use aoc::common::*;
use aoc::machine::*;
fn main() {
problem1("input.txt");
problem2("input.txt");
}
fn problem1(filename: &str) {
println!("1. Find the last accumulator value before failure");
let i = read_file(filename).expect("No File");
let instructions = parse_input(&i).unwrap();
le... | true |
5b618488d4c90466a74c042ee690f7b2cdaa5f42 | Rust | ROki1988/wain | /wain-exec/src/stack.rs | UTF-8 | 12,925 | 3.171875 | 3 | [
"MIT"
] | permissive | use crate::value::{LittleEndian, Value};
use std::cmp::Ordering;
use std::convert::{TryFrom, TryInto};
use std::f32;
use std::f64;
use std::fmt;
use std::mem::size_of;
use wain_ast::{AsValType, ValType};
// Vec<Value> consumes too much space since its element size is always 64bits.
// To use space more efficiently, he... | true |
3bcc104606db842b7f9213f7f50c5b950830de9a | Rust | riscv-rust/gd32vf103-pac | /src/dac.rs | UTF-8 | 4,002 | 2.578125 | 3 | [
"ISC"
] | permissive | #[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - control register"]
pub ctl: CTL,
#[doc = "0x04 - software trigger register"]
pub swt: SWT,
#[doc = "0x08 - DAC0 12-bit right-aligned data holding register"]
pub dac0_r12dh: DAC0_R12DH,
#[doc = "0x0c - DAC0 12-bi... | true |
0d46e2bdaa0f14baf66b795a3619e9e66d55f089 | Rust | knmsk/leftwm | /src/utils/window_updater.rs | UTF-8 | 977 | 2.75 | 3 | [
"MIT"
] | permissive | use crate::config::Config;
use crate::display_servers::DisplayServer;
use crate::models::Manager;
impl<C: Config, SERVER: DisplayServer> Manager<C, SERVER> {
/*
* step over all the windows for each workspace and updates all the things
* based on the new state of the WM
*/
pub fn update_windows(&... | true |
e4c682445f3138af32bc2a7d2f7da6a3ffb45697 | Rust | stackcats/leetcode | /algorithms/easy/left_and_right_sum_differences.rs | UTF-8 | 375 | 2.984375 | 3 | [
"MIT"
] | permissive | impl Solution {
pub fn left_right_difference(nums: Vec<i32>) -> Vec<i32> {
let mut right = nums.iter().sum::<i32>();
let mut left = 0;
let mut res = vec![0; nums.len()];
for (i, n) in nums.into_iter().enumerate() {
res[i] = (right - left - n).abs();
left += n;... | true |
c2d26ccae775eec249d19a91691879cd5bd56c7a | Rust | rodrimati1992/break_array | /src/lib.rs | UTF-8 | 1,699 | 3.796875 | 4 | [] | no_license | //! Want indexing arrays to not work anymore?
//!
//! Simply create a crate that depends on `break_array`:
//!
//! ```compile_fail
//! use break_array as _;
//! fn main(){
//! let array=[0,1,2,3];
//! assert_eq!( array[0], 0 );
//! }
//! ```
//! and marvel at the compiler error:
//! ```text
//! |
//! 6 | ... | true |
8898d79e00cb4ceb7bed4f7a510945d34516ba21 | Rust | AuroransSolis/aoc_2018 | /day_1/src/main.rs | UTF-8 | 2,071 | 3.015625 | 3 | [] | no_license | #![feature(test)]
fn main() {
let input = include_str!("../input.txt");
let input_vals = input.lines().map(|line| line.parse::<i64>().unwrap()).collect::<Vec<i64>>();
part_1(&input_vals);
part_2(&input_vals);
}
pub fn part_1(input: &Vec<i64>) {
println!("{}", input.iter().sum::<i64>());
}
pub fn ... | true |
1ba7ab0f0edaf7342f09c0e5336f492c7eb37cb4 | Rust | asyade/hydrobot-firmware | /hydrobot/src/gui/widgets/controler_details.rs | UTF-8 | 11,834 | 2.78125 | 3 | [] | no_license |
use termion::{event::Key};
use tui::{
layout::{Rect},
style::{Color, Style},
widgets::{Block, Borders},
widgets::{List, ListItem },
};
use std::time::Duration;
use std::collections::HashMap;
use super::super::*;
#[derive(Debug, Clone, Copy)]
pub enum ParamKind {
Boolean(bool),
Float(f64),
... | true |
6577cd8b2a19f59f56e1639c07d177e4698a6e73 | Rust | jimblandy/advent-of-code-2018 | /src/bin/day-12.rs | UTF-8 | 4,632 | 3 | 3 | [] | no_license | #![feature(copy_within)]
use std::iter::repeat;
#[allow(dead_code)]
static TEST_INPUT: &'static str = include_str!("day-12.test");
#[allow(dead_code)]
static INPUT: &'static str = include_str!("day-12.input");
type Rule = [bool; 32];
#[derive(Debug)]
struct State {
origin: isize,
pots: Vec<bool>,
}
fn pot_... | true |
5912a4401d5cd934ed199d2b07bb17f3bfc74056 | Rust | csnover/ritual | /cpp_core/src/convert.rs | UTF-8 | 2,624 | 2.9375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use crate::ptr::NullPtr;
use crate::{CppBox, CppDeletable, Ptr, Ref, StaticUpcast};
/// Performs some of the conversions that are available implicitly in C++.
///
/// `CastInto` is automatically implemented for all `CastFrom` conversions,
/// similar to `From` and `Into` traits from `std`.
pub trait CastFrom<T>: Sized... | true |
86ce57db995d801f5bf9d1e20c12ff883cf92956 | Rust | leosmerling/py-tonic | /src/lib.rs | UTF-8 | 2,021 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | mod event;
mod model;
mod server;
use std::time::Duration;
use log::{info, error};
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;
use pyo3_asyncio::tokio::into_coroutine;
use tokio::time::sleep;
use tonic::transport::Server;
use model::hw::greeter_server::{GreeterServer};
use server::MyGreeter;
#[pyo3_asyncio::... | true |
e7ad21edd0d6f288206ac1bf3270f4e3601ffbfd | Rust | courajs/pretty-sure | /src/lib.rs | UTF-8 | 2,202 | 4 | 4 | [] | no_license | //! Like `.unwrap()` or `.or_else()` for arbitrary patterns.
//!
//! I'm not so sure this is a great idea, but it's useful for prototyping at least!
/// When you're pretty sure something will match a pattern.
///
/// It simply expands to a two-branch match:
/// ```
/// sure!(val, pattern => result; otherwise);
/// //... | true |
41e6d649b6b9c5dec5daa89a465acbdb6f2b18fe | Rust | leshow/stanford-cs140e | /2-fs/fat32/src/vfat/ebpb.rs | UTF-8 | 4,101 | 2.578125 | 3 | [] | no_license | use std::{fmt, io, mem, str};
use traits::BlockDevice;
use vfat::Error;
#[repr(C, packed)]
pub struct BiosParameterBlock {
_r1: [u8; 3],
oem_ident: [u8; 8],
bytes_per_sec: u16,
sec_per_clus: u8,
rsvd_sec_count: u16,
num_fats: u8,
num_dir_entries: u16,
num_logical_sec_bpb: u16,
fat_... | true |
0b2832aee643aab309527754a938897b8ef193de | Rust | badboy/adventofcode2017 | /day01/main.rs | UTF-8 | 2,055 | 3.625 | 4 | [] | no_license | use std::io::prelude::*;
use std::fs::File;
fn captcha(input: &str) -> u32 {
let input = input.trim();
let len = input.len();
assert!(len > 1);
let chars = input
.chars()
.cycle()
.map(|c| c.to_digit(10).unwrap())
.take(len + 1)
.collect::<Vec<_>>();
chars.w... | true |
9681ce381f68a67411ba8effe06928cd2c31f9ff | Rust | krixi/remud | /remud-lib/tests/it/login.rs | UTF-8 | 6,492 | 2.75 | 3 | [
"MIT"
] | permissive | use std::time::Duration;
use crate::support::Server;
#[tokio::test]
async fn test_login_create_player() {
let (_server, _t) = Server::new_create_player("Shane", "s;kladjf").await;
}
#[tokio::test]
async fn test_login_create_verify_failed() {
let (_server, mut t) = Server::new_connect_telnet().await;
t.l... | true |
c21aaecfdd40951fcf4907c72141c1ffbb1ec076 | Rust | patm1987/rust_d20_test | /src/test_world.rs | UTF-8 | 369 | 2.796875 | 3 | [
"MIT"
] | permissive |
use map::Map;
use room::Room;
pub fn build_world() -> Map {
let start_room = Room::new(
"Foyer",
"You wake up in an empty foyer. Dust settles around you, your head throbbing. You have no recollection of why you are here",
"There is a large central staircase. To your left, a bookshelf. To your right, an unlit t... | true |
ebcd5e0253cf82835cb446642b05ac097efacde7 | Rust | letheed/divrem | /src/lib.rs | UTF-8 | 4,589 | 3.71875 | 4 | [
"MIT"
] | permissive | //! Division and modulus traits and implementations.
//!
//! There are several definitions for the division and modulus
//! functions, each with different properties.
//! Probably the most common in computer science is truncated division
//! (rounding towards zero) since it is the one provided by most processors
//! an... | true |
eec0b5c6935c0979da23669ce67699aab06306f7 | Rust | bcmcmill/rust-futures-backoff | /src/strategy/fixed_interval.rs | UTF-8 | 290 | 2.734375 | 3 | [
"MIT"
] | permissive | use std::iter::Iterator;
#[derive(Debug, Clone)]
pub struct FixedInterval {}
impl FixedInterval {
pub fn new() -> FixedInterval {
FixedInterval {}
}
}
impl Iterator for FixedInterval {
type Item = u32;
fn next(&mut self) -> Option<u32> {
Some(1)
}
}
| true |
e9965ecb86bdfba0572a890a751d46c073909fe7 | Rust | Plecra/gl46 | /src/struct_loader.rs | UTF-8 | 142,228 | 2.984375 | 3 | [
"Zlib"
] | permissive | use super::*;
impl GlFns {
/// Loads all GL functions from the loader given.
///
/// ## Failure
/// This fails if any non-nullable function does not load.
/// The error value will be the name of the first non-nullable function that
/// doesn't load.
///
/// ## Safety
/// * The "Get Proc Address" func... | true |
2240762043cf8988ca658a2224efd25393578898 | Rust | rust-lang/futures-rs | /futures-test/src/interleave_pending.rs | UTF-8 | 5,547 | 2.578125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use futures_core::future::{FusedFuture, Future};
use futures_core::stream::{FusedStream, Stream};
use futures_io::{
self as io, AsyncBufRead, AsyncRead, AsyncSeek, AsyncWrite, IoSlice, IoSliceMut, SeekFrom,
};
use futures_sink::Sink;
use pin_project::pin_project;
use std::{
pin::Pin,
task::{Context, Poll},
... | true |
4c85b19a793942b9ad535640fd460bdd7a3433fb | Rust | guoyucode/rbatis | /rbatis-core/src/mysql/value.rs | UTF-8 | 7,173 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | use crate::error::UnexpectedNullError;
use crate::mysql::{MySql, MySqlTypeInfo};
use crate::value::RawValue;
use crate::decode::Decode;
use crate::types::BigDecimal;
use crate::Result;
#[derive(Debug, Copy, Clone)]
pub enum MySqlData<'c> {
Binary(&'c [u8]),
Text(&'c [u8]),
}
#[derive(Debug, Clone)]
pub struct... | true |
7ddb7defcb5cc5752188285c4738432abc17b78c | Rust | performance/IDP_Analyzer | /src/image/other.rs | UTF-8 | 6,696 | 3.359375 | 3 | [] | no_license |
use traits::{ Primitive, Pixel, GenericImage };
use buffer::ImageBuffer;
use std::ops::{ Index, IndexMut };
use std::mem;
#[derive(Copy, PartialEq, Eq, Debug, Clone)]
pub enum PixelType {
Short16,
Float32
}
/// Result of a decoding process
pub enum DecodingResult {
/// A vector of unsigned bytes
U1... | true |
7aa57d3af42ec8489c6ed8927f44d453692e6c79 | Rust | appaquet/exocore | /discovery/src/server/config.rs | UTF-8 | 1,045 | 3.125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | use std::time::Duration;
/// Configuration for discovery service server.
#[derive(Copy, Clone)]
pub struct ServerConfig {
/// Port to listen on.
pub port: u16,
/// Maximum number of payloads that the server can stores.
pub max_payloads: usize,
/// Maximum payload size.
pub max_payload_size: u... | true |
7d230cca09a6131b9aff00c66c5f623d4863441c | Rust | jfrsmith/advent-2016 | /day_14/src/main.rs | UTF-8 | 3,107 | 3.15625 | 3 | [] | no_license | use std::io::prelude::*;
use std::fs::File;
use std::cmp;
#[derive(Debug)]
struct Reindeer<'a> {
name: &'a str,
speed: i32,
fly_time: i32,
rest_time: i32,
distance: i32,
score: i32,
is_flying: bool,
time_in_state: i32
}
fn main() {
let mut file = File::open("input/input.txt").unwrap... | true |
7639d2fe70a31688425fa4848b34594d4017717d | Rust | nocproject/noc | /rust/agent/src/proto/pktmodel/g711.rs | UTF-8 | 1,399 | 2.515625 | 3 | [
"BSD-3-Clause"
] | permissive | // ---------------------------------------------------------------------
// G.711 Packet model
// ---------------------------------------------------------------------
// Copyright (C) 2007-2021 The NOC Project
// See LICENSE for details
// ---------------------------------------------------------------------
use supe... | true |
4f042d0920035e076c50b1de008cc1adafa3eca0 | Rust | nakazono0424/meibo_management | /src/main.rs | UTF-8 | 6,735 | 3.109375 | 3 | [] | no_license | #[macro_use]
extern crate lazy_static;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::io::{BufWriter, Write};
struct Date {
y: u32,
m: u8,
d: u8,
}
//#[derive(Debug)]
struct Profile {
id: i32,
name: String,
birthday:Date,
home: String,
comment: String,
}
//mod app_cont... | true |
f832b83e002e05621c723186d1852e4036d0e554 | Rust | geo-engine/geoengine | /operators/src/util/rayon.rs | UTF-8 | 1,615 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use std::sync::Arc;
use rayon::{ThreadPool, ThreadPoolBuilder};
/// Tries to create a global thread pool that does not spawn any threads.
/// This prevents accidentally using it.
///
/// Hopefully, rayon either provides a real method for achieving this in the future
/// or does not fix this behavior.
///
/// Panics i... | true |
de71782a12cc26ee9495a909727f60242946a9c4 | Rust | sugyan/leetcode | /others/august-leetcoding-challenge-2021/week-1/3838/lib.rs | UTF-8 | 1,950 | 3.625 | 4 | [] | no_license | use std::cell::RefCell;
use std::rc::Rc;
use utils::TreeNode;
pub struct Solution;
impl Solution {
pub fn path_sum(root: Option<Rc<RefCell<TreeNode>>>, target_sum: i32) -> Vec<Vec<i32>> {
let mut answer = Vec::new();
Self::dfs(&root, target_sum, &mut Vec::new(), &mut answer);
answer
}
... | true |
a4b2b961ba15674d1eb8b2122a3847476c980272 | Rust | aaneto/beepbop | /src/macros.rs | UTF-8 | 861 | 2.890625 | 3 | [] | no_license | #[macro_export]
/// Macro for logging the result
/// and error of a future.
macro_rules! log_all {
($future_obj:expr) => {
$future_obj
.map(|data| {
println!("{:#?}", data);
()
})
.map_err(|err| {
println!("{:#?}", err);
... | true |
0a6c1ac7097f399e54749775fd8356d966de0c8c | Rust | stv0g/k66 | /src/sim/sopt8.rs | UTF-8 | 69,818 | 2.65625 | 3 | [
"MIT"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::SOPT8 {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut... | true |
2c6954df4afe4a0ab99e549169f9bd11e4198e94 | Rust | corocn/kana2phone | /src/main.rs | UTF-8 | 255 | 2.78125 | 3 | [
"MIT"
] | permissive | use kana2phone::kana2phone;
fn main() {
let s = readline();
let s = kana2phone(&s);
println!("{}", s);
}
fn readline() -> String {
let mut s = String::new();
std::io::stdin().read_line(&mut s).unwrap();
s.trim_end().to_owned()
}
| true |
14a8dc2e51e758132c4e356f6e9dd0785109fd84 | Rust | elauffenburger/sixty-five-oh-too | /src/cpu/instr/rotate.rs | UTF-8 | 3,950 | 2.859375 | 3 | [] | no_license | use super::InstrResult;
use super::Cpu;
use super::super::addr;
use util;
use std::fmt;
pub mod rol {
use super::InstrResult;
use super::Cpu;
use super::addr;
use super::Direction;
#[allow(unused_variables)]
pub fn acc(cpu: &mut Cpu) -> Box<InstrResult> {
rol(addr::acc(cpu), 1, 2)
... | true |
291556c57dc84a7e63edd5759b2945c5465fe68b | Rust | 95th/deno | /std/wasi/testdata/std_fs_file_sync_data.rs | UTF-8 | 446 | 2.65625 | 3 | [
"MIT"
] | permissive | // { "preopens": { "/scratch": "scratch" } }
use std::io::Write;
fn main() {
let mut file = std::fs::File::create("/scratch/file").unwrap();
assert!(file.write(b"Hello").is_ok());
assert!(file.sync_data().is_ok());
assert_eq!(std::fs::read("/scratch/file").unwrap(), b"Hello");
assert!(file.write(b", world... | true |
f33ab128a733b517e2528b6a8b56e2def0960d58 | Rust | csernazs/misc | /aoc/2022_rust/src/aoc2022/aoc_03.rs | UTF-8 | 1,671 | 3.296875 | 3 | [] | no_license | use std::collections::HashSet;
use std::fs::File;
use std::io::{BufRead, BufReader};
fn part01(lines: Vec<String>) -> usize {
let mut retval: usize = 0;
let letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZ";
for line in lines {
let left = line.get(0..line.len() / 2).unwrap();
... | true |
59cd8e201e014ae79550194f697d511445b1a5cc | Rust | royendgel/nginxlog | /src/main.rs | UTF-8 | 2,477 | 2.75 | 3 | [] | no_license | extern crate postgres;
extern crate getopts;
extern crate regex;
use postgres::{Connection, SslMode};
use std::io::BufReader;
use std::io::prelude::*;
use std::fs::File;
use std::io;
use std::path::Path;
use std::env;
use regex::Regex;
fn main() {
let mut nginx_path = String::new();
for (key, value) in env... | true |
97ae2d848ca86a2041bf91dd6f6012cd267c6e77 | Rust | Ajhaa/workhours_bot | /src/main.rs | UTF-8 | 4,361 | 2.78125 | 3 | [] | no_license | #[macro_use]
extern crate diesel;
pub mod models;
pub mod schema;
pub mod db;
use teloxide::{prelude::*, utils::command::BotCommand};
use chrono::Duration;
use dotenv::dotenv;
use std::env;
use self::db::*;
#[derive(BotCommand)]
#[command(rename = "lowercase", description = "These commands are supported:")]
enum C... | true |
195c62a8926316a6b0db48f01b263a079874737a | Rust | garyhai/hypergraph | /src/graph.rs | UTF-8 | 8,717 | 2.8125 | 3 | [
"MIT"
] | permissive | /*!
# Graph Oriented Modelling
根据GraphQL的规范,定义了Query, Mutation 和 Subscription 三个executing operations。基于此,Graph trait也实现上述三个methods:query, mutate, subscribe。
Graph 的核心是定位vertices并对其进行操作,然后返回结果。输入项被称为谓语:Predicate,输出项:Output。根据Rust的设计理念,Predicate作为输入项,采用generic parameter比较好,Output作为输出项,采用associated type为好。举一个例子,如果对于非对... | true |
0c9ed482882c8c8f69c84d4111f9e45a03b06925 | Rust | google/tock-on-titan | /kernel/h1/src/spi_host.rs | UTF-8 | 10,799 | 2.671875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
] | permissive | use crate::hil::spi_host::SpiHost;
use core::cell::Cell;
use core::cmp::min;
use kernel::common::cells::{OptionalCell, TakeCell};
use kernel::common::registers::{register_bitfields, register_structs, ReadOnly, ReadWrite, WriteOnly};
use kernel::common::StaticRef;
use kernel::hil::spi::{ClockPolarity, ClockPhase, SpiMas... | true |
51909532d2a60f90210d37a915d9f657cbfdf7e0 | Rust | cbreeden/font-shape | /src/table/hhea.rs | UTF-8 | 1,880 | 2.828125 | 3 | [] | no_license | use decode::primitives::{Tag, FWord, UFWord, Ignored};
use decode::{Error, Result, SizedTable, Table, Primitive, ReadPrimitive, ReadTable};
/// horizontal fonts header table
#[derive(Debug, Table)]
pub struct Hhea {
pub major_version: u16,
pub minor_version: u16,
pub ascent: FWord,
pub descent: FWord,
... | true |
b63eb2fcf91ffd8227ba0fab92ef2dda9ee75dda | Rust | deadshot465/torahiko | /src/structures/embed/mod.rs | UTF-8 | 4,760 | 2.84375 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize)]
pub struct EmbedObject {
pub title: Option<String>,
#[serde(rename = "type")]
pub kind: Option<String>,
pub description: Option<String>,
pub url: Option<String>,
pub color: Option<u32>,
pub footer: Option<EmbedFooter>,
... | true |
16f3907f97f1372a41ebb58f8588d8170d3778ae | Rust | hansung080/study | /rust/trpl/guessing-game/tests/guessing_game_test.rs | UTF-8 | 728 | 3.28125 | 3 | [] | no_license | mod common;
use std::cmp::Ordering;
use guessing_game as game;
use common::assert_err;
#[test]
fn can_exit() {
assert!(game::can_exit("exit"));
assert!(game::can_exit("quit"));
assert!(!game::can_exit("50"));
}
#[test]
fn compare() {
let answer = 50;
assert_err(game::compare("a", answer), "a shou... | true |
fc6953aa51ee4649f4815dd3da77c3959b51a9ca | Rust | tomyamkum/rust-shell | /src/main.rs | UTF-8 | 6,944 | 2.921875 | 3 | [] | no_license | extern crate dirs;
extern crate colored;
use std::ffi::CString;
use nix::unistd::*;
use nix::sys::wait::*;
use std::fs;
use std::io::prelude::*;
use shell::parser::parser;
use colored::*;
fn main() {
println!("使えるコマンドは以下");
println!("exit: プロセス終了");
println!("ls: ディレクトリ内ファイル一覧表示");
println!("cd: ディレクトリ移動");
prin... | true |
525a5a3fac3b6bb467619d8bfcee5954a8d95f41 | Rust | MinusGix/eyeutil | /src/zstring.rs | UTF-8 | 2,584 | 3.515625 | 4 | [] | no_license | use crate::{
parse::{take_until, Parse, ParseResult},
writable::{Writable, WriteResult},
};
use bstr::BString;
use std::io::{Read, Seek, Write};
/// Simple (ascii-ish, but more a byte-string) Null-terminated string.
/// Is not meant to work on unicode.
/// Does not store null-terminator, but does write it out ... | true |
f910d4b687db7f08eb500e96a629b6d3d9768018 | Rust | wolf4ood/orientdb-rs | /orientdb-client/src/sync/network/conn.rs | UTF-8 | 1,508 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | use crate::common::protocol::messages::request::HandShake;
use crate::common::protocol::messages::{Request, Response};
use crate::sync::protocol::WiredProtocol;
use crate::OrientResult;
use byteorder::{BigEndian, ReadBytesExt};
use std::io::Write;
use std::net::Shutdown;
use std::net::{SocketAddr, TcpStream};
pub stru... | true |
0682c786c818a363c546b05a6197d3a5c83bb2ca | Rust | rust-lang/rust | /src/tools/clippy/clippy_lints/src/transmute/transmute_null_to_fn.rs | UTF-8 | 2,103 | 2.75 | 3 | [
"Apache-2.0",
"MIT",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"LicenseRef-scancode-other-permissive"
] | permissive | use clippy_utils::consts::{constant, Constant};
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::{is_integer_literal, is_path_diagnostic_item};
use rustc_hir::{Expr, ExprKind};
use rustc_lint::LateContext;
use rustc_middle::ty::Ty;
use rustc_span::symbol::sym;
use super::TRANSMUTE_NULL_TO_FN;
fn l... | true |
313f5521ee0386ed5020c7487033c530158ae601 | Rust | jnhyatt/set-solver | /src/main.rs | UTF-8 | 1,443 | 3.1875 | 3 | [] | no_license | use itertools::Itertools;
use std::collections::HashMap;
use std::fmt;
use velcro::hash_map;
#[derive(Debug, PartialEq, Eq, Hash)]
enum Fill {
Empty,
Half,
Solid,
}
#[derive(Debug, PartialEq, Eq, Hash)]
enum Shape {
Circle,
Diamond,
Squiggle,
}
#[derive(Debug, PartialEq, Eq, Hash)]
enum Numbe... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.