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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
cdb476f22c83c051f874d5a67f2914558605a6a0 | Rust | TheNumerus/lensflaregen-rs | /src/lfg/ghost.rs | UTF-8 | 3,864 | 2.71875 | 3 | [] | no_license | use cgmath::{prelude::*, vec2, Deg, Matrix2, Matrix4, Vector2};
use gl_wrapper::{
geometry::{AttrSize, Geometry, GeometryBuilder, GeometryType},
shader::Shader,
};
use crate::window_state::WindowState;
pub struct Ghost {
pub color: [f32; 4],
pub offset: f32,
pub perpendicular_offset: f32,
pub... | true |
85f4b842313be99a6fea074019aac2519a3b57e7 | Rust | stackdump/rustpflow | /src/lib.rs | UTF-8 | 4,391 | 2.90625 | 3 | [
"MIT"
] | permissive | extern crate wasm_bindgen;
use std::collections::HashMap;
use wasm_bindgen::prelude::*;
// macro to construct hashes
macro_rules! map(
{ $($key:expr => $value:expr),+ } => {
{
let mut m = ::std::collections::HashMap::new();
$(
m.insert($key, $value);
)+
... | true |
4d8d199aa42a4a5f82803193c47778596e531bb1 | Rust | timvisee/copypasta-ext | /src/osc52.rs | UTF-8 | 4,407 | 3.375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! OSC 52 escape sequence to set clipboard contents.
//!
//! This provider can set clipboard contents by outputting a sequence to stdout in supported
//! terminals. It uses Xterm escape sequences, OSC 52 to be exact.
//!
//! Getting clipboard contents is not supported through this context and will error.
//!
//! ## Be... | true |
108efa30c5e7c9cfb0d9dc5d0ea2b57552d0459d | Rust | dstreet26/adventofcode | /2020/day7/src/main.rs | UTF-8 | 1,467 | 2.9375 | 3 | [] | no_license | use std::fs;
fn main() {
let contents = fs::read_to_string("input.txt").expect("Couldn't read input file :(");
let list: Vec<&str> = contents.split("\n").collect();
let mut count = 0;
let mut paths = vec![("shiny gold".to_string(), 1)];
while paths.len() > 0 {
let target2 = paths.pop().unwr... | true |
9785b1b65351bd6e40430aea996060ed5ff01d79 | Rust | YaMike/rust_course_notes | /p5RustControlFlow/src/cf.rs | UTF-8 | 861 | 3.921875 | 4 | [] | no_license | #![allow(dead_code)]
pub fn if_statement()
{
let temp = 33;
let upper_boundary = 30;
let lower_boundary = 10;
// regular if usage
if temp > upper_boundary
{
println!("temp {} is greater than {}", temp, upper_boundary);
}
else if temp < lower_boundary
{
println!("tem... | true |
042de068973197485cda4dd20fd77d9f9e0c0564 | Rust | alanhoff/rust-libfizzbuzz | /src/lib.rs | UTF-8 | 495 | 3.625 | 4 | [
"ISC"
] | permissive | // Detect if an i64 is divisible by 3
pub fn is_fizz(n: i64) -> bool {
n % 3 == 0
}
// Detect if an i64 is divisible by 5
pub fn is_buzz(n: i64) -> bool {
(n % 5) == 0
}
// Detect if an i64 is divisible by 3 and 5
pub fn is_fizzbuzz(n: i64) -> bool {
(n % 5) == 0 && (n % 3) == 0
}
// Detect if an i64 is fizz, ... | true |
15ffb08f30fdd1416c10a3420c7d2c3ba2de4085 | Rust | doy/rbw | /src/bin/rbw-agent/daemon.rs | UTF-8 | 2,088 | 2.734375 | 3 | [
"MIT"
] | permissive | pub struct StartupAck {
writer: std::os::unix::io::RawFd,
}
impl StartupAck {
pub fn ack(&self) -> anyhow::Result<()> {
nix::unistd::write(self.writer, &[0])?;
nix::unistd::close(self.writer)?;
Ok(())
}
}
impl Drop for StartupAck {
fn drop(&mut self) {
// best effort cl... | true |
3062e6b45aaa2d9985f47321d661b8f287297594 | Rust | origel/origel | /programs/userutils/src/bin/passwd.rs | UTF-8 | 3,574 | 2.578125 | 3 | [
"MIT"
] | permissive | extern crate rand;
extern crate syscall;
extern crate termion;
extern crate userutils;
use rand::{Rng, OsRng};
use std::{env, io};
use std::fs::File;
use std::io::{Read, Write};
use termion::input::TermRead;
use userutils::Passwd;
fn main() {
let stdin = io::stdin();
let mut stdin = stdin.lock();
let stdo... | true |
54220dbbfeaedce9b5ad214ee7706bd5c0c5d511 | Rust | Azure/azure-sdk-for-rust | /sdk/iot_hub/src/service/operations/update_or_replace_twin.rs | UTF-8 | 3,917 | 3.015625 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT",
"LGPL-2.1-or-later"
] | permissive | use azure_core::headers;
use azure_core::Method;
use serde::Serialize;
use std::collections::HashMap;
use crate::service::{ServiceClient, API_VERSION};
azure_core::operation! {
/// The UpdateOrReplaceTwinBuilder is used to construct a request for
/// updating or replacing a device or module twin.
UpdateOr... | true |
a5f48cb22dd762c8a9cb582d01cebe4259e9b5a0 | Rust | clankford/rust-tracer | /src/ray_tracer/ray.rs | UTF-8 | 10,852 | 3.765625 | 4 | [] | no_license | use crate::ray_tracer::tuple::Tuple;
use crate::ray_tracer::sphere::Sphere;
use crate::ray_tracer::intersection::Intersection;
use crate::ray_tracer::matrix::Matrix;
#[cfg(test)]
use crate::ray_tracer::traits::object::Object;
pub struct Ray {
//TODO: This doesn't feel safe becasue an origin HAS to be a point, not... | true |
2342e059004609c1bfb306bb53a7fccb94161fa2 | Rust | a-bakos/rust-playground | /archived-learning/consolo/src/card.rs | UTF-8 | 595 | 3.53125 | 4 | [] | no_license | #[derive(Copy, Clone, Debug)]
pub enum Color {
Red,
Green,
Blue,
Yellow,
Black,
}
#[derive(Copy, Clone, Debug)]
pub struct Card {
pub value: u8,
pub color: Color,
}
impl Card {
pub fn get_value(&self) -> u8 {
self.value
}
pub fn get_color(&self) -> String {
mat... | true |
99c2af8d1bda9afb715922b311f8b226500dcc46 | Rust | skyofsmith/servePractice | /rust/advanced/htype/src/main.rs | UTF-8 | 3,971 | 4.28125 | 4 | [
"MIT"
] | permissive | fn main() {
{
//1、类型别名
type Kilometers = i32;
let x: i32 = 5;
let y: Kilometers = 6;
let r: i32 = x + y;
println!("x + y = {}", r);
//类型别名的主要用途是减少重复。
//(1)考虑如下类型:
//Box<dyn Fn() + Send + 'static>
////如代码:
//let f: Box<dyn Fn() ... | true |
8da78e5ffff64ba78737afb3c2e8cc864812d32a | Rust | Im-Oab/One-Man-ggj21 | /src/image_assets.rs | UTF-8 | 8,562 | 2.953125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::time::Duration;
use tetra::graphics::{Mesh, Shader, Texture};
use tetra::Context;
use crate::sprite::AnimationMultiTextures;
/// Struct for a content data. One object per file.
pub struct ContentPath {
/// Key for access content after loaded
pub key: String,
/// Pa... | true |
e035afbfbbcc27fb40546ddcd8bb2ad6a5076ce9 | Rust | kalamay/vmap-rs | /src/io/mod.rs | UTF-8 | 8,421 | 3.390625 | 3 | [
"MIT"
] | permissive | //! Read/Write types for buffering.
//!
//! Both the [`Ring`](struct.Ring.html) and
//! [`InfiniteRing`](struct.InfiniteRing.html) are fixed size anonymous allocations
//! utilizing circular address mappinng. The circular mapping ensures that
//! the entire readable or writable slice may always be addressed as a single... | true |
79ff08f3a2015744b36ad86a02baef95870feb93 | Rust | erochest/straw-boss | /src/client/local/mod.rs | UTF-8 | 1,452 | 2.734375 | 3 | [] | no_license | use client::ManagerClient;
use messaging::{connect, Receiver, Sender};
use server::local::DOMAIN_SOCKET;
use server::{RequestMessage, ResponseMessage};
use service::Service;
use std::os::unix::net::UnixStream;
use std::path::PathBuf;
use tasks::TaskSpec;
use Result;
#[derive(Default)]
pub struct RestManagerClient {
... | true |
cd70358dae9041bdae36d345cc272f106cbea58b | Rust | 0b01/xeo | /src/node/peer.rs | UTF-8 | 363 | 2.953125 | 3 | [] | no_license | #[derive(Debug)]
pub struct PeerState {
pub pubkey: Option<Vec<u8>>,
}
impl PeerState {
pub fn new() -> Self {
PeerState { pubkey: None }
}
// pub fn with_pubkey(key: Vec<u8>) -> Self {
// PeerState { pubkey: Some(key) }
// }
pub fn set_key(&mut self, key: Vec<u8>) {
s... | true |
bc3411bda928f12413d7902afc8063ecb4b082fe | Rust | mangeption/leetcode-rust | /src/logger_rate_limiter/solution.rs | UTF-8 | 771 | 2.953125 | 3 | [] | no_license |
use std::collections::HashMap;
const RATE_LIMIT: i32 = 10;
pub struct Logger {
msgs: HashMap<String, i32>,
}
impl Logger {
/** Initialize your data structure here. */
pub fn new() -> Self {
Logger {
msgs: HashMap::new(),
}
}
pub fn should_print_message(&mut self, tim... | true |
0f08a7f689dbbffc8c5cf678a07237aba108235e | Rust | glebm/rsass | /src/functions/strings.rs | UTF-8 | 3,850 | 2.96875 | 3 | [] | no_license | use super::{Error, SassFunction};
use css::Value;
use num_traits::Signed;
use std::collections::BTreeMap;
use value::{Number, Quotes, Unit};
pub fn register(f: &mut BTreeMap<&'static str, SassFunction>) {
def!(f, quote(contents), |s| match s.get("contents") {
Value::Literal(v, _) => Ok(Value::Literal(v, Qu... | true |
5941a8ce259a72c962e2504b889751c452b8892e | Rust | ferrite-rs/ferrite-tutorial | /src/bin/07_rec_atm.rs | UTF-8 | 6,577 | 3.203125 | 3 | [] | no_license | use ferrite_session::prelude::*;
use std::time::Duration;
use tokio::time::sleep;
/*
# Excercise 7: Recursive ATM
- Implement an `atm_provider` that dispense cash if the client provides
the correct pin and the requested amount is lower than available balance.
- If incorrect pin is given, offer the WrongP... | true |
29e4a74351685b5cde702070ff793e5fc9f63e36 | Rust | async-raft/async-raft | /memstore/src/test.rs | UTF-8 | 13,242 | 2.515625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::collections::HashSet;
use super::*;
use async_raft::raft::EntryConfigChange;
const NODE_ID: u64 = 0;
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#[tokio::test]
async fn test_get_membership_conf... | true |
658fa3394635a31f2825546b0f14541317a88f3f | Rust | prince-pascoe/easigrow | /src/beta.rs | UTF-8 | 55,916 | 2.796875 | 3 | [
"MIT"
] | permissive | //! A variety of beta solutions for cracks in different shaped coupons.
//!
//! Beta functions relate the far field loading to the crack tip so
//! they are a function of the geometry and of the size of the crack
//! in the component. In all the functions here we use
//! non-dimensionalised factors. All the betas can b... | true |
30c5e57b7043a7fdc65737c6aa81417b6f644a2c | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/arc047/src/bin/a.rs | UTF-8 | 553 | 2.75 | 3 | [] | no_license | use proconio::input;
use proconio::marker::Chars;
fn main() {
input! {
_: usize,
l: usize,
s: Chars,
};
let mut crash_count = 0;
let mut count = 1;
for c in s {
match c {
'+' => {
count += 1;
}
'-' => {
... | true |
18b9ccaed953e94b4ea7adf6314665bd82ce2329 | Rust | WanzenBug/xch | /src/non_atomic.rs | UTF-8 | 3,861 | 3.359375 | 3 | [
"MIT"
] | permissive | use std::{
fs,
io,
path,
};
use uuid;
use crate::error::{Error, Result};
/// Exchange files/directories by non-atomic renames.
///
/// This tries to swap files or directories by calling `std::fs::rename` 3 times.
/// 1. Rename path1 to a temporary path
/// 2. Rename path2 to path1
/// 3. Rename the tempo... | true |
f6062f6ce0efce4d2289708d1eaa1d37a2eaa11e | Rust | jeremiah-shaulov/nop-json | /tests/all.rs | UTF-8 | 13,999 | 3.09375 | 3 | [
"MIT"
] | permissive | use nop_json::{Reader, Value, TryFromJson, ValidateJson, DebugToJson, WriteToJson, escape, escape_bytes};
use std::io::{self, Error};
use std::f32;
#[test]
fn test_number()
{ let mut reader = Reader::new(r#" 0 0.01 123 128 -128 -129 255 -1 -1e+2 1e2 123e-7 0.0123e-10 3000.0 -3000.0 1e-1000000 1e10000000000 "Infinity" ... | true |
393a9a3622a59c13aebe88e01f4f566280734008 | Rust | Wandalen/wSelector | /rust/test/selector/basic.rs | UTF-8 | 1,018 | 2.640625 | 3 | [
"MIT"
] | permissive | use test_tools::*;
//
tests_impls!
{
fn parse_query()
{
use wselector::TpathSegment::{ Name, Num };
let name = | n : &str | Name( n.to_string() );
for ( s, expected ) in vec!
[
( ".", Ok( vec![] ) ),
( "a", Ok( vec![ name( "a" ) ] ) ),
( "a.b", Ok( vec![ name("a"), name( "b" ) ] ... | true |
6f0c2c52f0178646681143e36cba6531662c84ea | Rust | abingham/roid-rage-rust | /roid-rage/src/systems/explode_bullets.rs | UTF-8 | 1,385 | 2.796875 | 3 | [] | no_license | use crate::components::{make_fragment, Bullet, Collision, Position};
use crate::core::util::random_bearing;
use rand::prelude::*;
use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System};
pub struct ExplodeBulletsSystem;
/// Explode bullets that have collided with something.
impl<'s> System<'s> for ExplodeB... | true |
3a39a6aaf3f55bb2361a534ce08aa0321e39019b | Rust | niuyuling/denyhosts | /clamav/libclamav_rust/.cargo/vendor/exr/examples/2_rgba_adjust_exposure.rs | UTF-8 | 3,115 | 3.234375 | 3 | [
"BSD-3-Clause"
] | permissive |
// exr imports
extern crate exr;
/// Read an rgba image, increase the exposure, and then write it back.
/// Uses multi-core compression where appropriate.
///
/// All non-rgba channels and all layers except the first rgba layers will not be present in the new file.
fn main() {
use exr::prelude::*;
... | true |
a802f2ce37f957d1d4f245427acbffc8455f7e09 | Rust | tiffany352/react-rs | /src/flat_tree.rs | UTF-8 | 8,868 | 3.140625 | 3 | [] | no_license | use std::collections::HashMap;
use std::hash::Hash;
use std::hash::Hasher;
use std::iter::repeat_with;
use std::marker::PhantomData;
pub struct NodeKey<Item> {
index: usize,
_phantom: PhantomData<Item>,
}
impl<Item> Clone for NodeKey<Item> {
fn clone(&self) -> Self {
*self
}
}
impl<Item> Copy... | true |
618efa17406eb0400e7e3c2d76d59e8a4eed00a8 | Rust | embed-rs/stm32f7x6 | /src/rcc/apb2lpenr/mod.rs | UTF-8 | 37,149 | 2.515625 | 3 | [] | no_license | #[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::APB2LPENR {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w... | true |
7ec25c8bb9a368a9268769fb9463e5eadb1e3ccd | Rust | yskszk63/btknmle | /src/input/mousestat.rs | UTF-8 | 2,227 | 2.84375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use std::io;
use bitflags::bitflags;
use tokio::io::{AsyncWrite, AsyncWriteExt};
use btknmle_input::event::pointer::{
Axis, ButtonState, PointerAxisEvent, PointerButtonEvent, PointerMotionEvent,
};
use btknmle_input::ButtonCodes;
bitflags! {
pub struct Button: u8 {
const LEFT = 0b0000_0001;
c... | true |
e5e410fbbbfa5d4073f5f91816c98d7106dd8660 | Rust | Zeda/mset-rust | /src/main.rs | UTF-8 | 2,692 | 3.25 | 3 | [] | no_license | extern crate image;
use image::{ImageBuffer, Rgb};
fn atou32(s : &str) -> u32{
let mut x = 0;
for c in s.chars(){
x = x*10+(c as u32-'0' as u32);
}
return x;
}
const CUTOFF : f64 = 256.0;
fn main() {
let args: Vec<_> = std::env::args().collect();
let width;
let height;
let max_... | true |
724bb0b07c83680784edf9d811e9557527a7e348 | Rust | sandialabs/Polymers | /src/physics/single_chain/fjc/thermodynamics/mod.rs | UTF-8 | 3,209 | 2.625 | 3 | [
"BSD-3-Clause"
] | permissive | #[cfg(feature = "python")]
pub mod py;
mod test;
/// The freely-jointed chain (FJC) model thermodynamics in the isometric ensemble.
pub mod isometric;
/// The freely-jointed chain (FJC) model thermodynamics in the isotensional ensemble.
pub mod isotensional;
/// The freely-jointed chain (FJC) model therm... | true |
f16da4eaa35089ee752de08539cb85b3cbc99ebc | Rust | jsdw/advent-of-code-2017 | /day25/solution/input.rs | UTF-8 | 2,966 | 2.96875 | 3 | [] | no_license | use std::collections::HashMap;
use self::Direction::*;
pub fn input() -> Blueprint {
Blueprint {
begin_in: 'A',
perform_checksum_after: 12994925,
commands: vec![
('A', State {
if_false: Command {
write: true,
move_to: Right... | true |
4fb7ddab3bf2aa7350b8f05fb8e1807dd4ae28c4 | Rust | NonJam/shipyard | /src/sparse_set/sort/mod.rs | UTF-8 | 685 | 3.140625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | mod unstable;
use super::SparseSet;
pub use unstable::*;
/// Trait used to sort storage(s).
pub trait IntoSortable {
type IntoSortable;
/// Doesn't sort the view(s) until an algorithm is chosen, `unstable` for example.
///
/// ### Example:
/// ```
/// use shipyard::{EntitiesViewMut, IntoSor... | true |
d3e1fbb352f7332099b80ab536288de99e8559e2 | Rust | TyOverby/stormtrooper | /src/svg.rs | UTF-8 | 3,095 | 3.015625 | 3 | [] | no_license | use std::io::Write;
use std::io::Result as IoResult;
use super::{Figure, Drawing};
const SVG_HEADER: &'static str = r#"<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/sv... | true |
d47ce43ec320dbaf8c5973cb0c6c49a669ec9c08 | Rust | spectrum-lumiere/cosmwasm | /packages/std/src/query/wasm.rs | UTF-8 | 810 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::Binary;
#[non_exhaustive]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum WasmQuery {
/// this queries the public API of another contract at a known address (with known ABI... | true |
a94e0adfcde5ad6b5fbf7e145c6a246d84d2bc83 | Rust | lattice0/www-authenticate | /src/lib.rs | UTF-8 | 43,731 | 2.5625 | 3 | [] | no_license | //! www-authenticate
//! missing HTTP WWW-Authenticate header parser/printer for hyper
//extern crate unicase;
//extern crate url;
use std::borrow::{Cow, Borrow};
use std::collections::HashMap;
use std::fmt;
use unicase::UniCase;
use std::io::Write;
#[cfg(feature = "digest")]
pub mod digest;
type Result<T> = std::res... | true |
a91e16136d5f1703702159636db6cc5a14d1d089 | Rust | ando-huang/rust | /hello/src/arrays.rs | UTF-8 | 663 | 3.703125 | 4 | [] | no_license | //this files goes over arrays
//arrays are fixed length, same data type
use std::mem;
pub fn run(){
let mut nums:[i32; 5] = [1,2,3,4,5]; //must have the fixed size of elems, EXACT
//let mut numbers: Vec<i32> = vec![1,2,3,4]; //now this is a vector definition
//main difference is that we can edit the vect... | true |
c940e361a55e79aeaff04ce4888427587cf69a27 | Rust | Eolu/htmlify | /src/lib.rs | UTF-8 | 4,159 | 3.34375 | 3 | [] | no_license | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))]
#[cfg(feature = "yew")]
pub mod yew;
#[cfg(feature = "yew")]
use ::yew::{html, Html};
use std::{borrow::Cow, fmt::Display};
/// Trait used to generate HTML from Rust structures. See module-level
/// documentation for more details.
pub trait H... | true |
2f02d7813cba4304a441f16f496873b90b8c4ce3 | Rust | Yuta1004/dragonbook | /src/chapter2/parser/_defparser.rs | UTF-8 | 5,418 | 3.359375 | 3 | [] | no_license | use super::super::lexer::Lexer;
use super::super::mtype::Type;
use super::super::token::{Token, Tag};
use super::super::symbol::{Symbol, SymbolTable};
/// 定義と使用からなるプログラムをパースする(未完成/失敗作)
///
/// # members
/// - lexer: Lexer => 字句解析器
/// - symboltable: SymbolTable => 記号表
#[allow(dead_code)]
struct DefParser {
lexer: ... | true |
00171b1b6319f57273f37c32dddea25675b888cb | Rust | TheRenegadeCoder/sample-programs | /archive/r/rust/longest-word.rs | UTF-8 | 587 | 3.71875 | 4 | [
"MIT"
] | permissive | use std::env::args;
use std::process::exit;
fn usage() -> ! {
println!("Usage: please provide a string");
exit(0);
}
fn get_longest_word_len(s: &str) -> usize {
s.trim()
.split_whitespace()
.map(|t| t.len())
.max()
.unwrap()
}
fn main() {
let mut args = args().skip(1);... | true |
a30f3c9032e99772bdfffe735fe4741c67b3ab14 | Rust | Devolutions/sarpine-rs | /sarpine/tests/mod.rs | UTF-8 | 1,419 | 2.703125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | extern crate sarpine;
use sarpine::srp_logic::Srp;
use sarpine::srp_logic::SrpState;
fn auth_test(user_pwd: &str) {
let password = "password";
let mut srp_client = Srp::new(false, user_pwd);
let mut srp_server = Srp::new(true, password);
let in_data = Vec::new();
let mut srp_initiate = Vec::new(... | true |
04f1c01c61f85f765cb4f3685d8d56f8c9f59da2 | Rust | Miaxos/poc-logux | /src/domain/messages/sync.rs | UTF-8 | 1,286 | 2.828125 | 3 | [] | no_license | use crate::domain::messages::error::WrongFormatErrorMessage;
use serde_json::Value;
pub struct SyncMessage {
/// Sync number, last added time used by receiver in previous connection,
/// 0 on first connection.
pub synced: u64,
pub actions: std::vec::Vec<Value>,
}
/// Function to decode a vec to PingMe... | true |
0c1df951322a1b52ef45a0d1bd1235a99e433de6 | Rust | wizardwatch/solve_string | /src/main.rs | UTF-8 | 7,696 | 3 | 3 | [
"Apache-2.0"
] | permissive | const EXPONENT: &str = "^";
const MULTIPLICATION: &str = "*";
const DIVISION: &str = "/";
const ADDITION: &str = "+";
const SUBTRACTION: &str = "~";
pub fn main(mut input: String) -> f32 {
//declares stuff.
let mut answer: f32 = 404.0;
let mut operator_places = vec![];
let mut current_letter;
let m... | true |
872f285bb9ba1299b57a03e1373263f61d43a34f | Rust | CompSciGuyIT/Rust_Projects | /syntax_and_semantics/functions/src/main.rs | UTF-8 | 950 | 4.25 | 4 | [] | no_license | fn main() {
print_number(5);
print_sum(4, 5);
println!("9 becomes {}", add_one(9));
println!("9 is entered, {} is returned", returns_odd(9));
println!("2 is entered, {} is returned", returns_odd(2));
let a: fn(i32) -> i32 = add_one;
let six = a(5);
println!("The value bound to six is: ... | true |
70b2951efa8d5e3b990709e4517d6fbd33b84d90 | Rust | kirjavascript/cakeybar | /src/wm/watch.rs | UTF-8 | 3,535 | 2.59375 | 3 | [
"MIT",
"Unlicense"
] | permissive | use inotify::{Inotify, WatchMask};
use crossbeam_channel as channel;
use std::{thread, time};
use crate::util::Timer;
use crate::wm::WMUtil;
use crate::config::Config;
use gtk;
enum WriteType {
Config,
Theme,
}
pub struct Watcher {
timer: Timer,
sender: channel::Sender<()>,
}
impl Watcher {
pub f... | true |
ff41406e988a12229704a85ad64f9b93bcdd8dbc | Rust | AlisCode/AdventOfCode2017 | /src/day7.rs | UTF-8 | 1,229 | 2.75 | 3 | [] | no_license | extern crate day7_parser;
use day7_parser::Process;
pub fn get_root_process<'a>(list: &'a Vec<Process>) -> &'a str {
let mut children_processes: Vec<&String> = Vec::new();
list.iter().for_each(|a| {
a.children_names.iter().for_each(|b| {
children_processes.push(&b);
});
});
... | true |
7d4fe93d8464ace92f7d69bfcbd91013ed678aca | Rust | insideoutclub/ElementsOfProgramming | /src/integers.rs | UTF-8 | 2,653 | 3.09375 | 3 | [] | no_license | // integers.h
// Copyright (c) 2009 Alexander Stepanov and Paul McJones
//
// Permission to use, copy, modify, distribute and sell this software
// and its documentation for any purpose is hereby granted without
// fee, provided that the above copyright notice appear in all copies
// and that both that copyright notic... | true |
c3a06bb97c6c718f89bd38ff3e80fc3b347ddcbd | Rust | mesalock-linux/crates-sgx | /vendor/num-bigint/src/monty.rs | UTF-8 | 3,284 | 3.3125 | 3 | [
"Apache-2.0",
"LGPL-3.0-or-later",
"MIT"
] | permissive | use integer::Integer;
use traits::Zero;
use biguint::BigUint;
struct MontyReducer<'a> {
n: &'a BigUint,
n0inv: u32,
}
// Calculate the modular inverse of `num`, using Extended GCD.
//
// Reference:
// Brent & Zimmermann, Modern Computer Arithmetic, v0.5.9, Algorithm 1.20
fn inv_mod_u32(num: u32) -> u32 {
... | true |
57039dede0e8651b7aff9d8dad8dc8cf299f3aba | Rust | michelhe/rustboyadvance-ng | /core/src/sound/interface.rs | UTF-8 | 1,570 | 2.671875 | 3 | [
"MIT"
] | permissive | use rustboyadvance_utils::audio::{AudioRingBuffer, SampleConsumer, SampleProducer};
pub type StereoSample<T> = [T; 2];
pub trait AudioInterface {
fn get_sample_rate(&self) -> i32 {
44100
}
/// Pushes stereo sample buffer into the audio device
/// Sample should be normilized to siged 16bit val... | true |
8e9fdd00452fcda037fa2d48b23c67c7036dafcd | Rust | chrisanderberg/euler | /rust/4.rs | UTF-8 | 1,188 | 3.78125 | 4 | [] | no_license | // https://projecteuler.net/problem=4
//
// A palindromic number reads the same both ways. The largest palindrome
// made from the product of two 2-digit numbers is 9009 = 91 × 99.
//
// Find the largest palindrome made from the product of two 3-digit
// numbers.
fn to_digits(num: u64) -> Vec<u64> {
let mut digits... | true |
71a448d6c2d6f6a051762213077dfa84bea21e24 | Rust | H2CO3/ring_api | /src/multipart.rs | UTF-8 | 15,092 | 3.5 | 4 | [
"MIT"
] | permissive | //! Serialize a value into a request multipart `Form`.
use std::borrow::Cow;
use serde::ser::{
Error as SerError,
Serialize,
Serializer,
SerializeSeq,
SerializeTuple,
SerializeTupleStruct,
SerializeTupleVariant,
SerializeMap,
SerializeStruct,
SerializeStructVariant,
};
use reqwe... | true |
7a2a0a824faaadd56ebeea7cdab5888c6bbd5db5 | Rust | ViFo89/RustHW01 | /src/problem1.rs | UTF-8 | 1,169 | 3.921875 | 4 | [] | no_license | /// Computes the sum of all elements in the input i32 slice named `slice`
pub fn sum(slice: &[i32]) -> i32 {
let mut sum: i32 = 0;
for i in slice {
sum += *i;
}
sum
}
/// Deduplicates items in the input vector `vs`. Produces a vector containing
/// the first instance of each distinct element of... | true |
5b67e74f9bcbf3749281811b2e8d2833026b89b5 | Rust | Proximyst/AOC2019 | /src/day11.rs | UTF-8 | 2,981 | 3 | 3 | [] | no_license | use crate::intcode::*;
use std::collections::HashMap;
const BLOCK: char = '█';
#[derive(Copy, Clone, Debug)]
pub enum Direction {
Up,
Left,
Down,
Right,
}
impl Direction {
fn left(self) -> Self {
match self {
Self::Up => Self::Left,
Self::Left => Self::Down,
... | true |
94743a4c67e1b281f8aade7c1a0d4afb3e25af5a | Rust | pwil3058/rs_ord_set_ops_iter | /ord_set_iter_set_ops/benches/benchmark.rs | UTF-8 | 5,385 | 2.84375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use criterion::{criterion_group, criterion_main, Criterion};
use ord_set_iter_set_ops::*;
use std::collections::BTreeSet;
pub fn peekable_benchmark(c: &mut Criterion) {
let set = BTreeSet::<&str>::from(["a", "b", "c", "g", "e", "f"]);
let mut group = c.benchmark_group("OSISO: Peekable overhead");
group.be... | true |
fa8030d36ff18e9a3b8d796d9299f37dc378e86f | Rust | pierg75/cs110l-spr-2020-starter-code | /week3/linked_list/src/linked_list.rs | UTF-8 | 3,581 | 3.515625 | 4 | [
"MIT"
] | permissive | use std::fmt;
use std::option::Option;
use std::iter::Sum;
use std::ops::{Add, Mul};
pub trait ComputeNorm {
fn compute_norm(&self) -> u64;
}
#[derive(Debug)]
pub struct LinkedList<T> {
head: Option<Box<Node<T>>>,
size: usize,
}
#[derive(Debug, Clone, PartialEq)]
struct Node<T> {
value: T,
next:... | true |
19fe56c7e3ebcb3daf9b69747212bfdaa481b808 | Rust | shaunstanislauslau/jormungandr | /jormungandr-scenario-tests/src/style.rs | UTF-8 | 2,083 | 2.5625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! centralized styles for the different items to display.
#![allow(non_upper_case_globals)]
use console::Style;
pub mod icons {
//! icons are not meant to add some SWAG to the display, not to use as
//! a reference items. When using Icons, remember some users don't have
//! unicode compatible/enabled te... | true |
b85aab7a9df42abdf08d3698e02713c3c9e27303 | Rust | Noskcaj19/discord-stats | /src/error.rs | UTF-8 | 858 | 2.53125 | 3 | [] | no_license | use toml::de::Error as TomlDeserializeError;
#[derive(Debug)]
pub enum StoreError {
Sqlite(rusqlite::Error),
JsonError(serde_json::Error),
}
impl From<rusqlite::Error> for StoreError {
fn from(e: rusqlite::Error) -> Self {
StoreError::Sqlite(e)
}
}
impl From<serde_json::Error> for StoreError ... | true |
0c2b9d421adc10dacafacfce02ae6b9311561840 | Rust | philgeb/AoC2015 | /task2.rs | UTF-8 | 1,109 | 3.28125 | 3 | [] | no_license | use std::io::BufReader;
use std::io::prelude::*;
use std::fs::File;
struct Box {
l: u32,
w: u32,
h: u32,
}
fn part1 (boxes: &Vec<Box>) {
let mut total = 0;
for b in boxes {
let &smallest = [b.l * b.w, b.l * b.h, b.w * b.h].iter().min().unwrap();
let area = 2 * b.l * b.w + 2 * b.l *... | true |
263c6b3e5b4a08b970cb041fa50d7bc0c5d3a3be | Rust | ykwmz/leetcode-rust | /src/title_to_number.rs | UTF-8 | 1,416 | 3.90625 | 4 | [
"MIT"
] | permissive | // 给你一个字符串 columnTitle ,表示 Excel 表格中的列名称。返回该列名称对应的列序号。
//
//
//
// 例如,
//
// A -> 1
// B -> 2
// C -> 3
// ...
// Z -> 26
// AA -> 27
// AB -> 28
// ...
// 1 <= columnTitle.length <= 7
// columnTitle 仅由大写英文组成
// columnTitle 在范围 ["A", "FXSHRXW"] 内
//
pub fn title_to_number(column_title:... | true |
4ed08696a32500c20657f3f39a00a7f0a7058848 | Rust | mipli/septem | /src/roman.rs | UTF-8 | 5,509 | 3.703125 | 4 | [
"MIT"
] | permissive | use std::fmt::{Display, Formatter, Result as FmtResult};
use std::{ops, str};
use crate::{Digit, Error, Result};
/// A Roman number
///
/// Stores the value internally a u32
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)]
pub struct Roman(u32);
impl Roman {
/// Creates a Roman numeral for any value... | true |
4035df5166810e36fa0910e194caeced05aa8b53 | Rust | beingflo/tm-rs | /src/input.rs | UTF-8 | 667 | 2.921875 | 3 | [] | no_license | use std::env::Args;
use std::fs::File;
use std::io;
use std::fmt;
pub fn get_input(args: Args) -> Result<File, InputError> {
let arg = args.skip(1).next().ok_or(InputError::NoArgument)?;
Ok(File::open(arg)?)
}
pub enum InputError {
IOError(io::Error),
NoArgument,
}
impl From<io::Error> for InputError... | true |
14af59c847bdc794cb4dd6d8bd4eb7613fc06300 | Rust | VengeQ/simple_snake-rust-sdl2 | /src/snake_game/scores.rs | UTF-8 | 1,731 | 3.109375 | 3 | [] | no_license | use std::fs::{File, DirBuilder};
use std::io::{Read, Write};
use regex::Regex;
fn read_from_file_or_create(file_name: &str) -> String {
let mut content = String::new();
let file = File::open(file_name);
if file.is_ok() {
file.unwrap().read_to_string(&mut content).unwrap();
if &content == "... | true |
628cc336bca452313889f88e031dbf07b253ee59 | Rust | Liao062/lotus | /src/cache.rs | UTF-8 | 3,656 | 2.78125 | 3 | [
"MIT"
] | permissive | use std::ops::Deref;
use chrono::Duration;
use r2d2::Pool;
use r2d2_redis::RedisConnectionManager;
use redis::{cmd, ConnectionAddr, ConnectionInfo};
use serde::{de::DeserializeOwned, ser::Serialize};
use serde_json;
use super::errors::Result;
const BAD_PROVIDER: &'static str = "bad cache provider";
pub fn get<K, V,... | true |
43cee18197c5a7855c00641d48a007fa1660b8db | Rust | say3no/try_rust | /tour/src/chapter7_OOP/tour85_generif_function_shorthand.rs | UTF-8 | 935 | 3.640625 | 4 | [] | no_license | struct SeaCreature {
pub name: String,
noise: String,
}
impl SeaCreature {
pub fn get_sound(&self) -> &str {
&self.noise
}
}
trait NoiseMaker {
fn make_noise(&self);
}
impl NoiseMaker for SeaCreature {
fn make_noise(&self) {
println!("{}", self.get_sound());
}
}
fn generi... | true |
a1d5073d079a48a801da7d484c1aafaaee0fae1f | Rust | mesalock-linux/parity-scale-codec-sgx | /sgx/parity-scale-codec-sgx-test/enclave/src/decode_all.rs | UTF-8 | 1,831 | 3.1875 | 3 | [
"Apache-2.0"
] | permissive | use alloc::vec::Vec;
use parity_scale_codec::{
Error,
Decode,
Encode,
Input,
Compact,
EncodeLike,
DecodeAll
};
/// The error message returned when `decode_all` fails.
const DECODE_ALL_ERR_MSG: &str = "Input buffer has still data left after decoding!";
macro_rules! test_decode_all {
(
... | true |
a96b07480e5a6bc8556a3830911ec08644e9b313 | Rust | claranceliberi/rust-by-examples | /13-attributes/2-crates.rs | UTF-8 | 595 | 2.921875 | 3 | [
"MIT"
] | permissive | // The crate_type attribute can be used to tell the compiler whether a crate is a binary or a library (and even which type of library),
// and the crate_name attribute can be used to set the name of the crate.
// This crate is a library
#![crate_type = "lib"]
// The library is named "rary"
#![crate_name = "rarysss"]... | true |
bbcc9c06f683162cb112c555ff1a11697f3adc25 | Rust | mplanchard/rust-challenges | /src/almost_increasing_sequence.rs | UTF-8 | 2,305 | 3.46875 | 3 | [] | no_license |
fn is_increasing(seq: &[i32]) -> bool {
seq.iter().fold(
(0, true),
|acc, i| {
if acc.1 == false {acc} else {(*i, *i > acc.0)}
}
).1
}
fn increasing_blocks(seq: &[i32]) -> Vec<&[i32]> {
let mut indices = Vec::new();
let mut start = 0;
let mut prev = &seq[0];
... | true |
1eb0cdde3a5530835d206934c1535e3ff61cb8b8 | Rust | osaware/rCore-N | /os/src/console.rs | UTF-8 | 2,337 | 2.765625 | 3 | [
"MIT"
] | permissive | use core::fmt;
use crate::uart::print;
/// Use ANSICON to format colorized string
#[macro_export]
macro_rules! colorize {
($content: ident, $foreground_color: ident) => {
format_args!("\x1b[{}m{}\x1b[0m", $foreground_color as u8, $content)
};
($content: ident, $foreground_color: ident, $background... | true |
c4a264c37dc21e12a9f5446d5fd15689d2e0ac31 | Rust | funkill/yaml-validator | /yaml-validator/src/error.rs | UTF-8 | 6,877 | 2.953125 | 3 | [
"MIT"
] | permissive | #![macro_use]
use thiserror::Error;
#[cfg(feature = "smallvec")]
pub type PathVec<'a> = smallvec::SmallVec<[PathSegment<'a>; 8]>;
#[cfg(not(feature = "smallvec"))]
pub type PathVec<'a> = Vec<PathSegment<'a>>;
#[cfg(test)]
#[cfg(feature = "smallvec")]
macro_rules! path{
( $( $x:expr ),* ) => {
smallvec![
... | true |
d3daac0b5ce78fc25c7d1c611373b337ded5ff1e | Rust | AlmostBearded/config_struct | /config_struct/src/json_parsing.rs | UTF-8 | 2,118 | 2.90625 | 3 | [
"MIT"
] | permissive | use serde_json::{self, Value};
use crate::{
error::GenerationError,
options::StructOptions,
parsing,
value::{GenericStruct, GenericValue},
};
pub fn parse_json(json: &str, options: &StructOptions) -> Result<GenericStruct, GenerationError> {
use parsing::ParsedFields;
let json_struct: ParsedFi... | true |
07a76089c9e55e5d0cb78f0b34468cae20c63d13 | Rust | hackwave/segurodb | /segurodb/src/record/record.rs | UTF-8 | 4,415 | 3.453125 | 3 | [] | no_license | use byteorder::{LittleEndian, ByteOrder};
use field::view::FieldsView;
/// Optional size of header for variable-len records.
pub const HEADER_SIZE: usize = 4;
/// Value size
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum ValueSize {
/// Variable record size (needs to be read from header).
Variable,
/// Constan... | true |
d2fbf4681f0368fb8e9a78d40b016704f5fba830 | Rust | kasumi8pon/atcoder_practice | /other_contests/dp/src/bin/a.rs | UTF-8 | 483 | 2.5625 | 3 | [] | no_license | use proconio::input;
fn main() {
input! {
n: usize,
h: [i32; n]
}
let mut dp = Vec::new();
for i in 0..n {
if i == 0 {
dp.push(0);
} else if i == 1 {
dp.push((h[i] - h[i - 1]).abs());
} else {
dp.push(std::cmp::min(
... | true |
d842f29c994a4d79d40a2d544b35703967e8488e | Rust | CuriousCI/spid-rocket | /lib/attributes.rs | UTF-8 | 1,571 | 3 | 3 | [
"Apache-2.0"
] | permissive | use chrono::naive::NaiveDate;
pub struct Attributes {
/// # [Attributi identificativi](https://docs.italia.it/italia/spid/spid-regole-tecniche/it/stabile/attributi.html#id1)
/// Codice identificativo
pub spid_code: String,
/// Nome
pub name: String,
/// Cognome
pub family_name: String,
/// Luogo di nascita... | true |
d2a8e7eca20f88ec65454a02ea770abee6d0d197 | Rust | Telixia/rust_practice | /src/main.rs | UTF-8 | 4,154 | 2.8125 | 3 | [] | no_license | // #[allow(unused_imports)]
// #[allow(dead_code)]
// mod sum;
// mod sum_array;
// mod sum_array_target;
// mod reverse_integer;
// mod max_numbers;
// mod palindrome;
// mod longest_prefix;
// mod sorted_list_without_dupl_len;
// mod remove_element_from_list;
// mod detect_insertion;
// mod string_to_int;
// mod ve... | true |
d66941e3e5902828debbf2fb6819b0583888d9f6 | Rust | kguinto/the-rust-book | /integer-averages/src/lib.rs | UTF-8 | 1,005 | 3.203125 | 3 | [] | no_license | use std::collections::HashMap;
use std::f32::NAN;
pub fn get_mean(nums: &Vec<i32>) -> f32 {
if nums.len() == 0 {
return NAN;
}
let mut sum = 0;
for num in nums.iter() {
sum += *num;
}
sum as f32 / nums.len() as f32
}
pub fn get_median(nums: &Vec<i32>) -> f32 {
if nums.le... | true |
8a4ff01da151c309f0af5629fa360b8c615937ea | Rust | wess/boilerplates | /rust/axum/src/styles/mod.rs | UTF-8 | 1,442 | 2.8125 | 3 | [] | no_license | use std::sync::{
Arc,
RwLock
};
use axum::{
Router,
routing::get,
extract::{
Path,
State,
},
response::IntoResponse,
};
struct StyleState {
scss:String
}
impl StyleState {
fn new(path:&str) -> Self {
Self {
scss: string!(path)
}
}
}
type SharedState = Arc<RwLock<StyleStat... | true |
32d85604ee3b44025837301c698919c094ec2073 | Rust | jonathanfisher/max32650-rs | /src/hpb.rs | UTF-8 | 4,667 | 2.53125 | 3 | [] | no_license | #[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Controller Status Register."]
pub status: STATUS,
#[doc = "0x04 - Interrupt Enable Control Register."]
pub inten: INTEN,
#[doc = "0x08 - Interrupt Status Register."]
pub intfl: INTFL,
_reserved3: [u8; 4usize],
... | true |
c3d6cccbff6b097ceb88222aa5d0b02aed8fd847 | Rust | Milkitic/kbinxml-rs | /src/writer/buffer.rs | UTF-8 | 7,212 | 2.828125 | 3 | [] | no_license | use std::io::{Error, Result, Write};
use encoding::Encoding;
use crate::{traits::BigEndianBinaryWrite, types::BoxResult, util::codec::Sixbit};
pub struct NodeBufferWriter<'a> {
stream: Vec<u8>,
compressed: bool,
encoding: &'a dyn Encoding,
}
impl NodeBufferWriter<'_> {
pub fn new_with_code_name(comp... | true |
0b224ea0750eee59a99d39e2fa8f3eca906a3da6 | Rust | frgomes/openapi-tide | /examples/MVP/mvp.gen.rs | UTF-8 | 8,348 | 2.703125 | 3 | [] | no_license | /// The Foo API
mod server {
pub mod components {
pub mod schemas {
#[derive(::serde::Serialize, ::serde::Deserialize)]
/// Whether maybeGetName should return name
pub struct Req {
pub some: ::std::option::Option<bool>,
}
#[derive... | true |
8e21375eb36b1f10f2a018e0fd1627f81b198bfb | Rust | jeremybobbin/browser | /src/entry.rs | UTF-8 | 1,221 | 2.796875 | 3 | [] | no_license | extern crate termion;
use crate::{
types::*,
};
use termion::{
color::{
Blue,
Red,
Magenta,
Reset,
Fg
},
cursor::{
Goto,
Left,
Down,
},
style::{
self,
Bold,
NoBold
}
};
use std::{
io::{
sel... | true |
55a77109d9d1a93cbe4ed60582ee24a35807dd53 | Rust | 0xdeafbeef/nekoton-flutter | /core/src/macros.rs | UTF-8 | 1,550 | 3.265625 | 3 | [] | no_license | /// Converts c string to String
#[macro_export]
macro_rules! cstr_to_string {
($stri:expr, $ret_val:expr) => {
match ::std::ffi::CString::from_raw($stri).to_str() {
Ok(a) => a.to_string(),
Err(e) => {
::log::error!("Failed decoding {}: {}", stringify!($stri), e);
... | true |
c636c4c812a3f144ba2e59d3bdc23ed83107ba18 | Rust | wkcn/leetcode | /1401-1500/1470-shuffle-the-array.rs | UTF-8 | 313 | 3.609375 | 4 | [] | no_license | struct Solution {}
impl Solution {
pub fn shuffle(nums: Vec<i32>, n: i32) -> Vec<i32> {
let n = n as usize;
nums[..n].iter().zip(nums[n..].iter()).map(|x| vec![*x.0, *x.1]).flatten().collect()
}
}
fn main() {
assert_eq!(Solution::shuffle(vec![2,5,1,3,4,7], 3), vec![2,3,5,4,1,7]);
}
| true |
db8bb2da99d5473bbcedd924ba480daa293f6d31 | Rust | swc-project/swc | /crates/swc_css_parser/src/parser/input.rs | UTF-8 | 16,436 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use std::{borrow::Cow, fmt::Debug, mem::take};
use swc_atoms::Atom;
use swc_common::{BytePos, Span, Spanned, SyntaxContext};
use swc_css_ast::{ComponentValue, FunctionName, ListOfComponentValues, Token, TokenAndSpan};
use super::PResult;
use crate::error::{Error, ErrorKind};
pub trait ParserInput: Clone + Iterator<I... | true |
6967475f309adc4313d9182957c9dcbf8c76a81a | Rust | marceloboeira/trpl | /chapters/chapter-6/example1.rs | UTF-8 | 351 | 2.765625 | 3 | [
"MIT"
] | permissive | enum IpAddrKind {
V4,
V6,
}
fn print_iptype(ip: IpAddrKind) {
match ip {
IpAddrKind::V4 => println!("This is version is 4"),
IpAddrKind::V6 => println!("This is version is 6")
}
}
fn main() {
let iptype1 = IpAddrKind::V4;
let iptype2 = IpAddrKind::V6;
print_iptype(iptype1)... | true |
d47cf3ddd488ac7bdff15b1f0d1f8c6081c9084f | Rust | taiki-e/cargo-llvm-cov | /src/regex_vec.rs | UTF-8 | 4,602 | 2.671875 | 3 | [
"MIT",
"NCSA",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // TODO: this may no longer needed since regex 1.9.
use std::mem;
use anyhow::Result;
use regex::Regex;
pub(crate) struct RegexVecBuilder {
filled: Vec<String>,
current: String,
first: bool,
num_pats: usize,
leading: &'static str,
trailing: &'static str,
}
impl RegexVecBuilder {
const LI... | true |
dbedf16e780e3e056ca6d00032ba9c3a078fb66b | Rust | johndaniels/rusttls | /lib/src/diffie_helman.rs | UTF-8 | 3,247 | 3 | 3 | [] | no_license | use super::eliptic_curve::curve25519::{curve25519, curve25519_base};
use super::eliptic_curve::secp256r1::{secp256r1, secp256r1_base};
use super::messages::ParseError;
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum DiffieHellmanGroup {
/* Elliptic Curve Groups (ECDHE) */
Secp256r1,
Secp384r1,
Secp52... | true |
4d6fae10a86288ca0e17023cc0b7a4fa855cbb32 | Rust | v4kst1z/leetcode | /solution/src/solution_0003_longest_substring_without_repeating_characters.rs | UTF-8 | 570 | 3.265625 | 3 | [] | no_license | use std::collections::HashMap;
pub struct Solution {}
impl Solution {
pub fn length_of_longest_substring(s: String) -> i32 {
if s.is_empty() { return 0; }
let mut map = HashMap::new();
let mut max = 0;
let mut start;
let mut id = 0;
for (key, elem) in s.c... | true |
3b5afefd3c1b902fefc259ce92cd0c57dab23e28 | Rust | doytsujin/yew | /examples/nested_list/src/item.rs | UTF-8 | 1,233 | 3 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use yew::prelude::*;
use crate::Hovered;
#[derive(PartialEq, Clone, Properties)]
pub struct Props {
#[prop_or_default]
pub hide: bool,
pub on_hover: Callback<Hovered>,
pub name: String,
#[prop_or_default]
pub children: Children,
}
pub struct ListItem;
impl Component for ListItem {
type M... | true |
817baf285dede65f26ecd1255f1615ec0cd9386b | Rust | rust-rocksdb/rust-rocksdb | /src/write_batch.rs | UTF-8 | 10,512 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 Tyler Neely
//
// 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 in writ... | true |
8fb755f634c12f225025cd03455ce275653a1d72 | Rust | Turboshell/turboshell | /src/commands/keytool.rs | UTF-8 | 2,019 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | use libc;
use rustc_serialize::base64;
use rustc_serialize::base64::ToBase64;
use std::fs::File;
use std::io;
use std::io::{BufRead, BufReader, Write};
use std::path::PathBuf;
use seedfile;
fn has_stdin() -> bool {
unsafe { return libc::isatty(libc::STDIN_FILENO) == 0 };
}
pub fn main<W: Write>(out: &mut W, see... | true |
c3c13bb0acadacfcd9b1fbe4f87e1d09e849614e | Rust | sharnoff/passman | /src/subcmd/emit_plaintext.rs | UTF-8 | 992 | 2.703125 | 3 | [
"MIT"
] | permissive | //! Emits the plaintext version of a file
use super::print_err_and_exit;
use crate::version;
use std::fs;
use std::path::PathBuf;
#[derive(clap::Args)]
pub struct Args {
/// Sets the input file to read from
#[clap(short, long, name = "INPUT")]
input: PathBuf,
/// Sets the output file to write to
... | true |
fbd582004f5212143b73add65b5d5ae477d013cf | Rust | DennisVanEe/rust_prism | /rust_prism/src/fileio/ply.rs | UTF-8 | 13,626 | 2.5625 | 3 | [] | no_license | use crate::geometry::mesh::{Mesh, Triangle};
use pmath::vector::{Vec2, Vec3};
use rply;
use simple_error::{bail, SimpleResult};
use std::ffi::{CStr, CString};
use std::mem::MaybeUninit;
use std::os::raw;
use std::ptr;
extern "C" fn error_cb(_: rply::p_ply, message: *const raw::c_char) {
let err_msg = unsafe { CStr... | true |
73f6a11e5cf7a759588ed47ca118d3d463f7963d | Rust | tshepang/polonius | /polonius-parser/src/ir.rs | UTF-8 | 2,154 | 3.265625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #[derive(Debug)]
pub struct Input {
pub universal_regions: Vec<String>,
pub blocks: Vec<Block>,
pub var_uses_region: Vec<(String, String)>,
pub var_drops_region: Vec<(String, String)>,
}
impl Input {
pub fn new(
universal_regions: Vec<String>,
var_uses_region: Option<Vec<(String, St... | true |
6b331d4bc125a374cb5eae9f6607ba0015d8e037 | Rust | CNife/leetcode | /rust/finished/src/merge_intervals.rs | UTF-8 | 801 | 3.1875 | 3 | [] | no_license | pub fn merge(mut intervals: Vec<Vec<i32>>) -> Vec<Vec<i32>> {
intervals.sort_unstable_by_key(|interval| (interval[0], interval[1]));
let mut stack: Vec<Vec<i32>> = Vec::new();
for interval in intervals {
match stack.last_mut() {
Some(left) if left[1] >= interval[0] => {
... | true |
42c2b14299a43f6fab8b6fb9f117e75fd2502669 | Rust | kobigurk/cpsnarks-set | /src/utils/curve.rs | UTF-8 | 6,576 | 2.84375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! A simple abstraction for curves and fields, to wrap the Zexe and dalek-cryptography curves.
use rand::{CryptoRng, RngCore};
use rug::Integer;
quick_error! {
#[derive(Debug)]
pub enum CurveError {
CannotWrite {}
}
}
pub trait Field
where
Self: Clone + Sized,
{
fn modulus() -> Integer;
... | true |
4cc80c27650bc22118f64248c38280448db28ffc | Rust | azdavis/advent-of-code | /years/y2016/src/d01.rs | UTF-8 | 1,924 | 3.421875 | 3 | [
"MIT"
] | permissive | use helpers::{Compass, HashSet};
use std::ops::ControlFlow;
enum Dir {
Left,
Right,
}
fn parse(s: &str) -> impl Iterator<Item = (Dir, u32)> + '_ {
s.trim().split(", ").map(|s| {
let mut iter = s.chars();
let dir = match iter.next().unwrap() {
'L' => Dir::Left,
'R' => Dir::Right,
c => p... | true |
de6061b7ae5a52967e6a93f4e7659960d8aa7275 | Rust | hecsalazarf/bjsys | /proto/src/stub/raft.rs | UTF-8 | 14,917 | 2.734375 | 3 | [] | no_license | /// Client Request
#[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)]
pub struct ClientRequest {
#[prost(string, tag = "1")]
pub client: ::prost::alloc::string::String,
#[prost(uint64, tag = "2")]
pub serial: u64,
#[prost(oneof = "client_request::Request", tags = "3, 4, 5"... | true |
7e9df72aca8431bf0e08a75ec9bb63b3d18146c6 | Rust | Niedzwiedzw/templar | /templar/src/lib.rs | UTF-8 | 6,324 | 3.71875 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | /*!
Templar is both a Rust library and a CLI tool for working with templates. The usage and style is
inspired by both Jinja2 and Ansible, though it is not intended to be a clone of either of these.
The goal of the project is to provide fast and flexible dynamic templating, particularly for use with
configurations and ... | true |
265596dfc0127442fce1026fc8e1a010c45af9de | Rust | iCodeIN/rust-http2 | /ci-gen/src/yaml.rs | UTF-8 | 2,283 | 3.46875 | 3 | [
"MIT"
] | permissive | #[derive(Clone)]
pub enum Yaml {
String(String),
Int(i64),
List(Vec<Yaml>),
Map(Vec<(String, Yaml)>),
Bool(bool),
}
impl Yaml {
pub fn to_yaml_rust(&self) -> yaml_rust::Yaml {
match self {
Yaml::String(s) => yaml_rust::Yaml::String(s.clone()),
Yaml::List(l) => ya... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.