This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let v = vec!["apple", "apple", "apple", "banana", "orange"]; | |
| let target = String::from("apple"); | |
| let mut it = v.into_iter().skip_while(|s| s == &&target); // or predicate can also be |s| **s == target | |
| println!("{:?}", it.next()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let mut it = s.chars(); | |
| { | |
| let mut jt = it.by_ref().peekable(); | |
| if jt.peek() == Some(&'H') { | |
| jt.next(); | |
| } | |
| } | |
| println!("{:?}", it.next()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let mut it = s.chars(); | |
| let mut jt = it.clone().peekable(); | |
| if jt.peek() == Some(&'H') { | |
| jt.next(); | |
| it.next(); // <- duplication of code :( | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let s = String::from("Hello, rust"); | |
| let mut it = s.chars(); | |
| let mut jt = it.peekable(); | |
| it.next(); // <- value used here after move!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Draw3DAgent->CreateDynMeshElemDelegate.BindLambda( | |
| [this](const FSceneView* View, class FPrimitiveDrawInterface* PDI, const FMatrix& LocalToWorld) | |
| { | |
| FVector CameraX, CameraY; | |
| UDraw3DAgentComponent::GetCameraAxis(View, CameraX, CameraY); | |
| FVector Loc = GetActorLocation(); | |
| DrawCircle(PDI, Loc, CameraX, CameraY, FLinearColor::Red, 20.f, 16, SDPG_Foreground, 3.f); | |
| PDI->DrawLine(Loc, Loc + FVector::ForwardVector * 10.f, FLinearColor::Red, SDPG_Foreground); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "Sandbox.h" | |
| #include "Draw3DAgentComponent.h" | |
| UDraw3DAgentComponent::UDraw3DAgentComponent(const FObjectInitializer& ObjectInitializer) | |
| : Super(ObjectInitializer) | |
| { | |
| bHiddenInGame = false; | |
| bCastDynamicShadow = false; | |
| bDrawOnlyIfSelected = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| #include "Draw3DAgentComponent.generated.h" | |
| UENUM(BlueprintType) | |
| enum class ESceneDepthPriorityGroupProxy : uint8 | |
| { | |
| /** World scene DPG. */ | |
| SDPGP_World UMETA(DisplayName="World"), | |
| /** Foreground scene DPG. */ | |
| SDPGP_Foreground UMETA(DisplayName="Foreground") |